ismx-nexo-node-app 0.4.115 → 0.4.117
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -221,8 +221,8 @@ class RepositoryDatabasePostgres extends RepositoryDatabase_1.default {
|
|
|
221
221
|
return this.query(query, values).then((result) => { var _a, _b; return (_b = (_a = result[0]) === null || _a === void 0 ? void 0 : _a.list) !== null && _b !== void 0 ? _b : []; });
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
|
-
selectHash(
|
|
225
|
-
return __awaiter(this,
|
|
224
|
+
selectHash(tableName_1, select_1) {
|
|
225
|
+
return __awaiter(this, arguments, void 0, function* (tableName, select, filters = {}) {
|
|
226
226
|
if (!this.tables[tableName])
|
|
227
227
|
throw new Error(`table ${tableName} does not exist`);
|
|
228
228
|
let schema = this.tables[tableName][0].schema;
|
|
@@ -234,16 +234,16 @@ class RepositoryDatabasePostgres extends RepositoryDatabase_1.default {
|
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
236
|
run(name_1) {
|
|
237
|
-
return __awaiter(this, arguments, void 0, function* (name, params = [], filters) {
|
|
237
|
+
return __awaiter(this, arguments, void 0, function* (name, params = [], filters = {}) {
|
|
238
238
|
var _a;
|
|
239
239
|
let { where, values } = this.anyWhere(filters);
|
|
240
|
-
let placeholders = (_a =
|
|
240
|
+
let placeholders = (_a = params === null || params === void 0 ? void 0 : params.map((_, index) => "$" + (index + 1 + where.length))) !== null && _a !== void 0 ? _a : [];
|
|
241
241
|
let query = `SELECT ${name}(${placeholders.join(',')}) WHERE ${where}`;
|
|
242
242
|
return this.query(query, [...values, ...params]);
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
245
|
runValue(name_1) {
|
|
246
|
-
return __awaiter(this, arguments, void 0, function* (name, params = [], filters) {
|
|
246
|
+
return __awaiter(this, arguments, void 0, function* (name, params = [], filters = {}) {
|
|
247
247
|
return this.run(name, params, filters).then((result) => { var _a; return Object.values((_a = result[0]) !== null && _a !== void 0 ? _a : {})[0]; });
|
|
248
248
|
});
|
|
249
249
|
}
|
|
@@ -51,7 +51,7 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase {
|
|
|
51
51
|
select(tableName: string, select: string, filters?: {
|
|
52
52
|
[key: string]: Valuable | Array<Valuable>;
|
|
53
53
|
}): Promise<string[]>;
|
|
54
|
-
selectHash<T>(tableName: string, select: string, filters
|
|
54
|
+
selectHash<T>(tableName: string, select: string, filters?: Partial<T>): Promise<Hash<Primitive>>;
|
|
55
55
|
run<T>(name: string, params?: Valuable[], filters?: Partial<T>): Promise<T[]>;
|
|
56
56
|
runValue<T>(name: string, params?: Valuable[], filters?: Partial<T>): Promise<Valuable | undefined>;
|
|
57
57
|
toWhere(tableName: string, filters?: {
|
package/package.json
CHANGED
|
@@ -193,7 +193,7 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
|
|
|
193
193
|
return this.query<{list:string[]}>(query, values).then((result) => result[0]?.list ?? []);
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
async selectHash<T>(tableName: string, select: string, filters: Partial<T>): Promise<Hash<Primitive>>
|
|
196
|
+
async selectHash<T>(tableName: string, select: string, filters: Partial<T> = {}): Promise<Hash<Primitive>>
|
|
197
197
|
{
|
|
198
198
|
if (!this.tables[tableName]) throw new Error(`table ${tableName} does not exist`);
|
|
199
199
|
let schema = this.tables[tableName][0].schema;
|
|
@@ -204,15 +204,15 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
|
|
|
204
204
|
return this.query<{list:Record<Primitive, null>}>(query, values).then((result) => new Hash(result[0]?.list ?? {}));
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
async run<T>(name: string, params: Valuable[] = [], filters
|
|
207
|
+
async run<T>(name: string, params: Valuable[] = [], filters: Partial<T> = {}): Promise<T[]>
|
|
208
208
|
{
|
|
209
209
|
let { where, values } = this.anyWhere(filters as any);
|
|
210
|
-
let placeholders =
|
|
210
|
+
let placeholders = params?.map((_, index) => "$"+(index+1+where.length)) ?? [];
|
|
211
211
|
let query = `SELECT ${name}(${placeholders.join(',')}) WHERE ${where}`;
|
|
212
212
|
return this.query<any>(query, [ ...values, ...params ])
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
async runValue<T>(name: string, params: Valuable[] = [], filters
|
|
215
|
+
async runValue<T>(name: string, params: Valuable[] = [], filters: Partial<T> = {}): Promise<Valuable | undefined> {
|
|
216
216
|
return this.run<T>(name, params, filters).then((result) => Object.values(result[0] ?? {})[0] as Valuable)
|
|
217
217
|
}
|
|
218
218
|
|