@sdflc/backend-helpers 1.0.75 → 1.0.76
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,7 @@ class BaseGateway {
|
|
|
129
130
|
let filtersAppliedQty = 1;
|
|
130
131
|
if (arr.length > 0) {
|
|
131
132
|
filtersAppliedQty++;
|
|
132
|
-
query = query.whereIn(this.
|
|
133
|
+
query = query.whereIn(this.getIdFieldUpdateRemove(), arr.map((item) => item[this.getIdField()]));
|
|
133
134
|
}
|
|
134
135
|
if (hasStatus === true) {
|
|
135
136
|
filtersAppliedQty++;
|
|
@@ -283,6 +284,9 @@ class BaseGateway {
|
|
|
283
284
|
getIdField() {
|
|
284
285
|
return this.config.idField || constants_1.ID_FIELD;
|
|
285
286
|
}
|
|
287
|
+
getIdFieldUpdateRemove() {
|
|
288
|
+
return this.config.idFieldUpdateRemove || this.config.idField || constants_1.ID_FIELD;
|
|
289
|
+
}
|
|
286
290
|
get(id) {
|
|
287
291
|
return __awaiter(this, void 0, void 0, function* () {
|
|
288
292
|
return this.loader.load(id);
|
package/package.json
CHANGED