ismx-nexo-node-app 0.4.151 → 0.4.153
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.
|
@@ -227,7 +227,8 @@ class RepositoryDatabasePostgres extends RepositoryDatabase_1.default {
|
|
|
227
227
|
throw new Error(`table ${tableName} does not exist`);
|
|
228
228
|
let schema = this.tables[tableName][0].schema;
|
|
229
229
|
let { where, values } = this.toWhere(tableName, filters);
|
|
230
|
-
let
|
|
230
|
+
let column = PostgresUtils_1.default.snakeToCamel(select);
|
|
231
|
+
let query = `SELECT json_agg(u.${column}) as list FROM ${schema}.${tableName} u WHERE ${where}`;
|
|
231
232
|
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 : []; });
|
|
232
233
|
});
|
|
233
234
|
}
|
|
@@ -237,9 +238,10 @@ class RepositoryDatabasePostgres extends RepositoryDatabase_1.default {
|
|
|
237
238
|
throw new Error(`table ${tableName} does not exist`);
|
|
238
239
|
let schema = this.tables[tableName][0].schema;
|
|
239
240
|
let { where, values } = this.toWhere(tableName, filters);
|
|
241
|
+
let column = PostgresUtils_1.default.snakeToCamel(select);
|
|
240
242
|
let query = `
|
|
241
|
-
SELECT json_object_agg(t.${
|
|
242
|
-
FROM ( SELECT DISTINCT u.${
|
|
243
|
+
SELECT json_object_agg(t.${column}, NULL) as list
|
|
244
|
+
FROM ( SELECT DISTINCT u.${column} FROM ${schema}.${tableName} u WHERE ${where} ) t`;
|
|
243
245
|
return this.query(query, values).then((result) => { var _a, _b; return new Repository_1.Hash((_b = (_a = result[0]) === null || _a === void 0 ? void 0 : _a.list) !== null && _b !== void 0 ? _b : {}); });
|
|
244
246
|
});
|
|
245
247
|
}
|
package/package.json
CHANGED
|
@@ -199,7 +199,8 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
|
|
|
199
199
|
if (!this.tables[tableName]) throw new Error(`table ${tableName} does not exist`);
|
|
200
200
|
let schema = this.tables[tableName][0].schema;
|
|
201
201
|
let { where, values } = this.toWhere(tableName, filters);
|
|
202
|
-
let
|
|
202
|
+
let column = PostgresUtils.snakeToCamel(select);
|
|
203
|
+
let query = `SELECT json_agg(u.${column}) as list FROM ${schema}.${tableName} u WHERE ${where}`
|
|
203
204
|
return this.query<{list:string[]}>(query, values).then((result) => result[0]?.list ?? []);
|
|
204
205
|
}
|
|
205
206
|
|
|
@@ -208,9 +209,10 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
|
|
|
208
209
|
if (!this.tables[tableName]) throw new Error(`table ${tableName} does not exist`);
|
|
209
210
|
let schema = this.tables[tableName][0].schema;
|
|
210
211
|
let { where, values } = this.toWhere(tableName, filters as any);
|
|
212
|
+
let column = PostgresUtils.snakeToCamel(select);
|
|
211
213
|
let query = `
|
|
212
|
-
SELECT json_object_agg(t.${
|
|
213
|
-
FROM ( SELECT DISTINCT u.${
|
|
214
|
+
SELECT json_object_agg(t.${column}, NULL) as list
|
|
215
|
+
FROM ( SELECT DISTINCT u.${column} FROM ${schema}.${tableName} u WHERE ${where} ) t`;
|
|
214
216
|
return this.query<{list:Record<Primitive, null>}>(query, values).then((result) => new Hash(result[0]?.list ?? {}));
|
|
215
217
|
}
|
|
216
218
|
|
|
@@ -230,7 +232,8 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
|
|
|
230
232
|
return this.query<any>(query, [ ...values, ...params ]);
|
|
231
233
|
}
|
|
232
234
|
|
|
233
|
-
async runValue<T>(name: string, params: Valuable[] = [], filters: Partial<T> = {}): Promise<Valuable | undefined>
|
|
235
|
+
async runValue<T>(name: string, params: Valuable[] = [], filters: Partial<T> = {}): Promise<Valuable | undefined>
|
|
236
|
+
{
|
|
234
237
|
return this.run<T>(name, params, filters).then((result) => Object.values(result[0] ?? {})[0] as Valuable)
|
|
235
238
|
}
|
|
236
239
|
|