@sdflc/backend-helpers 1.0.91 → 1.0.92
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.js +26 -11
- package/build/esm/BaseGateway.js +26 -11
- package/package.json +1 -1
package/build/BaseGateway.js
CHANGED
|
@@ -112,8 +112,7 @@ class BaseGateway {
|
|
|
112
112
|
// This function should be overriden
|
|
113
113
|
const { hasStatus } = this.config;
|
|
114
114
|
const arr = filterParams ? (0, lodash_1.castArray)(filterParams) : [];
|
|
115
|
-
|
|
116
|
-
let filtersAppliedQty = 1;
|
|
115
|
+
let filtersAppliedQty = 0;
|
|
117
116
|
const idName = this.getIdFieldUpdateRemove();
|
|
118
117
|
const ids = [];
|
|
119
118
|
for (let filter of arr) {
|
|
@@ -121,9 +120,6 @@ class BaseGateway {
|
|
|
121
120
|
ids.push(filter[idName]);
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
|
-
console.warn('onRemoveFilter. arr = ', arr);
|
|
125
|
-
console.warn('onRemoveFilter. idName = ', idName);
|
|
126
|
-
console.warn('onRemoveFilter. ids = ', ids);
|
|
127
123
|
if (ids.length > 0) {
|
|
128
124
|
filtersAppliedQty++;
|
|
129
125
|
query.whereIn(idName, ids);
|
|
@@ -334,7 +330,11 @@ class BaseGateway {
|
|
|
334
330
|
}
|
|
335
331
|
const items = await query;
|
|
336
332
|
if (items.length > 0 && this.config.noCache !== true) {
|
|
337
|
-
items.forEach((item) =>
|
|
333
|
+
items.forEach((item) => {
|
|
334
|
+
if (item[this.getIdField()]) {
|
|
335
|
+
this.loader.clear(item[this.getIdField()]);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
338
|
}
|
|
339
339
|
return items;
|
|
340
340
|
}
|
|
@@ -349,7 +349,11 @@ class BaseGateway {
|
|
|
349
349
|
results.push(...items);
|
|
350
350
|
}
|
|
351
351
|
if (results.length > 0 && this.config.noCache !== true) {
|
|
352
|
-
results.forEach((item) =>
|
|
352
|
+
results.forEach((item) => {
|
|
353
|
+
if (item[this.getIdField()]) {
|
|
354
|
+
this.loader.clear(item[this.getIdField()]);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
353
357
|
}
|
|
354
358
|
return results;
|
|
355
359
|
}
|
|
@@ -362,7 +366,11 @@ class BaseGateway {
|
|
|
362
366
|
}
|
|
363
367
|
const items = await query;
|
|
364
368
|
if (items.length > 0 && this.config.noCache !== true) {
|
|
365
|
-
items.forEach((item) =>
|
|
369
|
+
items.forEach((item) => {
|
|
370
|
+
if (item[this.getIdField()]) {
|
|
371
|
+
this.loader.clear(item[this.getIdField()]);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
366
374
|
}
|
|
367
375
|
return items;
|
|
368
376
|
}
|
|
@@ -375,7 +383,11 @@ class BaseGateway {
|
|
|
375
383
|
}
|
|
376
384
|
const items = await query;
|
|
377
385
|
if (items.length > 0 && this.config.noCache !== true) {
|
|
378
|
-
items.forEach((item) =>
|
|
386
|
+
items.forEach((item) => {
|
|
387
|
+
if (item[this.getIdField()]) {
|
|
388
|
+
this.loader.clear(item[this.getIdField()]);
|
|
389
|
+
}
|
|
390
|
+
});
|
|
379
391
|
}
|
|
380
392
|
return items;
|
|
381
393
|
}
|
|
@@ -432,14 +444,17 @@ class BaseGateway {
|
|
|
432
444
|
const object = await this.transformOnRemove();
|
|
433
445
|
query.update(object).returning(this.config.returnFields);
|
|
434
446
|
}
|
|
435
|
-
console.warn('gw.remove returnFields', this.config.returnFields);
|
|
436
447
|
const filtersAppliedQty = await this.onRemoveFilter(query, where);
|
|
437
448
|
if (filtersAppliedQty == null || filtersAppliedQty <= 0) {
|
|
438
449
|
throw new Error(`Failed to remove records in the table '${this.config.table}' as none of filters applied: ${JSON.stringify(where, null, 2)}`);
|
|
439
450
|
}
|
|
440
451
|
const items = await query;
|
|
441
452
|
if (items.length > 0 && this.config.noCache !== true) {
|
|
442
|
-
items.forEach((item) =>
|
|
453
|
+
items.forEach((item) => {
|
|
454
|
+
if (item[this.getIdField()]) {
|
|
455
|
+
this.loader.clear(item[this.getIdField()]);
|
|
456
|
+
}
|
|
457
|
+
});
|
|
443
458
|
}
|
|
444
459
|
return items;
|
|
445
460
|
}
|
package/build/esm/BaseGateway.js
CHANGED
|
@@ -106,8 +106,7 @@ class BaseGateway {
|
|
|
106
106
|
// This function should be overriden
|
|
107
107
|
const { hasStatus } = this.config;
|
|
108
108
|
const arr = filterParams ? castArray(filterParams) : [];
|
|
109
|
-
|
|
110
|
-
let filtersAppliedQty = 1;
|
|
109
|
+
let filtersAppliedQty = 0;
|
|
111
110
|
const idName = this.getIdFieldUpdateRemove();
|
|
112
111
|
const ids = [];
|
|
113
112
|
for (let filter of arr) {
|
|
@@ -115,9 +114,6 @@ class BaseGateway {
|
|
|
115
114
|
ids.push(filter[idName]);
|
|
116
115
|
}
|
|
117
116
|
}
|
|
118
|
-
console.warn('onRemoveFilter. arr = ', arr);
|
|
119
|
-
console.warn('onRemoveFilter. idName = ', idName);
|
|
120
|
-
console.warn('onRemoveFilter. ids = ', ids);
|
|
121
117
|
if (ids.length > 0) {
|
|
122
118
|
filtersAppliedQty++;
|
|
123
119
|
query.whereIn(idName, ids);
|
|
@@ -328,7 +324,11 @@ class BaseGateway {
|
|
|
328
324
|
}
|
|
329
325
|
const items = await query;
|
|
330
326
|
if (items.length > 0 && this.config.noCache !== true) {
|
|
331
|
-
items.forEach((item) =>
|
|
327
|
+
items.forEach((item) => {
|
|
328
|
+
if (item[this.getIdField()]) {
|
|
329
|
+
this.loader.clear(item[this.getIdField()]);
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
332
|
}
|
|
333
333
|
return items;
|
|
334
334
|
}
|
|
@@ -343,7 +343,11 @@ class BaseGateway {
|
|
|
343
343
|
results.push(...items);
|
|
344
344
|
}
|
|
345
345
|
if (results.length > 0 && this.config.noCache !== true) {
|
|
346
|
-
results.forEach((item) =>
|
|
346
|
+
results.forEach((item) => {
|
|
347
|
+
if (item[this.getIdField()]) {
|
|
348
|
+
this.loader.clear(item[this.getIdField()]);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
347
351
|
}
|
|
348
352
|
return results;
|
|
349
353
|
}
|
|
@@ -356,7 +360,11 @@ class BaseGateway {
|
|
|
356
360
|
}
|
|
357
361
|
const items = await query;
|
|
358
362
|
if (items.length > 0 && this.config.noCache !== true) {
|
|
359
|
-
items.forEach((item) =>
|
|
363
|
+
items.forEach((item) => {
|
|
364
|
+
if (item[this.getIdField()]) {
|
|
365
|
+
this.loader.clear(item[this.getIdField()]);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
360
368
|
}
|
|
361
369
|
return items;
|
|
362
370
|
}
|
|
@@ -369,7 +377,11 @@ class BaseGateway {
|
|
|
369
377
|
}
|
|
370
378
|
const items = await query;
|
|
371
379
|
if (items.length > 0 && this.config.noCache !== true) {
|
|
372
|
-
items.forEach((item) =>
|
|
380
|
+
items.forEach((item) => {
|
|
381
|
+
if (item[this.getIdField()]) {
|
|
382
|
+
this.loader.clear(item[this.getIdField()]);
|
|
383
|
+
}
|
|
384
|
+
});
|
|
373
385
|
}
|
|
374
386
|
return items;
|
|
375
387
|
}
|
|
@@ -426,14 +438,17 @@ class BaseGateway {
|
|
|
426
438
|
const object = await this.transformOnRemove();
|
|
427
439
|
query.update(object).returning(this.config.returnFields);
|
|
428
440
|
}
|
|
429
|
-
console.warn('gw.remove returnFields', this.config.returnFields);
|
|
430
441
|
const filtersAppliedQty = await this.onRemoveFilter(query, where);
|
|
431
442
|
if (filtersAppliedQty == null || filtersAppliedQty <= 0) {
|
|
432
443
|
throw new Error(`Failed to remove records in the table '${this.config.table}' as none of filters applied: ${JSON.stringify(where, null, 2)}`);
|
|
433
444
|
}
|
|
434
445
|
const items = await query;
|
|
435
446
|
if (items.length > 0 && this.config.noCache !== true) {
|
|
436
|
-
items.forEach((item) =>
|
|
447
|
+
items.forEach((item) => {
|
|
448
|
+
if (item[this.getIdField()]) {
|
|
449
|
+
this.loader.clear(item[this.getIdField()]);
|
|
450
|
+
}
|
|
451
|
+
});
|
|
437
452
|
}
|
|
438
453
|
return items;
|
|
439
454
|
}
|