@sdflc/backend-helpers 1.0.75 → 1.0.77
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.
package/build/BaseGateway.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ declare class BaseGateway {
|
|
|
26
26
|
getDb(): Database;
|
|
27
27
|
getBuilder(): any;
|
|
28
28
|
getIdField(): string;
|
|
29
|
+
getIdFieldUpdateRemove(): string;
|
|
29
30
|
get(id: any): Promise<any>;
|
|
30
31
|
getMany(ids: any[]): Promise<any>;
|
|
31
32
|
buildListQuery(args?: BuildListQueryArgsInterface): Promise<any>;
|
package/build/BaseGateway.js
CHANGED
|
@@ -81,8 +81,9 @@ class BaseGateway {
|
|
|
81
81
|
if (hasLang && (filterParams === null || filterParams === void 0 ? void 0 : filterParams[constants_1.FIELDS.LANG]) != undefined) {
|
|
82
82
|
query.whereIn(`${table}.${constants_1.FIELDS.LANG}`, (0, lodash_1.castArray)(filterParams === null || filterParams === void 0 ? void 0 : filterParams[constants_1.FIELDS.LANG]));
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
const idField = this.getIdField();
|
|
85
|
+
if (filterParams === null || filterParams === void 0 ? void 0 : filterParams[idField]) {
|
|
86
|
+
query.whereIn(idField.includes('.') ? `${idField}` : `${table}.${idField}`, (0, lodash_1.castArray)(filterParams === null || filterParams === void 0 ? void 0 : filterParams[idField]));
|
|
86
87
|
}
|
|
87
88
|
if (fieldForKeyword && filterParams.keyword) {
|
|
88
89
|
query.whereRaw(`${fieldForKeyword} ILIKE ?`, `%${filterParams.keyword}%`);
|
|
@@ -97,7 +98,7 @@ class BaseGateway {
|
|
|
97
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
98
99
|
// This function should be overriden
|
|
99
100
|
const { hasStatus, hasVersion } = this.config;
|
|
100
|
-
const idName = this.
|
|
101
|
+
const idName = this.getIdFieldUpdateRemove();
|
|
101
102
|
let filtersAppliedQty = 0;
|
|
102
103
|
if (filterParams[idName]) {
|
|
103
104
|
filtersAppliedQty++;
|
|
@@ -129,7 +130,8 @@ class BaseGateway {
|
|
|
129
130
|
let filtersAppliedQty = 1;
|
|
130
131
|
if (arr.length > 0) {
|
|
131
132
|
filtersAppliedQty++;
|
|
132
|
-
|
|
133
|
+
const idName = this.getIdFieldUpdateRemove();
|
|
134
|
+
query = query.whereIn(idName, arr.map((item) => item[idName]));
|
|
133
135
|
}
|
|
134
136
|
if (hasStatus === true) {
|
|
135
137
|
filtersAppliedQty++;
|
|
@@ -283,6 +285,9 @@ class BaseGateway {
|
|
|
283
285
|
getIdField() {
|
|
284
286
|
return this.config.idField || constants_1.ID_FIELD;
|
|
285
287
|
}
|
|
288
|
+
getIdFieldUpdateRemove() {
|
|
289
|
+
return this.config.idFieldUpdateRemove || this.config.idField || constants_1.ID_FIELD;
|
|
290
|
+
}
|
|
286
291
|
get(id) {
|
|
287
292
|
return __awaiter(this, void 0, void 0, function* () {
|
|
288
293
|
return this.loader.load(id);
|
package/package.json
CHANGED