@sdflc/backend-helpers 1.0.89 → 1.0.90

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.
@@ -112,6 +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
+ console.warn('onRemoveFilter', filterParams);
115
116
  let filtersAppliedQty = 1;
116
117
  const idName = this.getIdFieldUpdateRemove();
117
118
  const ids = [];
@@ -120,8 +121,12 @@ class BaseGateway {
120
121
  ids.push(filter[idName]);
121
122
  }
122
123
  }
124
+ console.warn('onRemoveFilter. arr = ', arr);
125
+ console.warn('onRemoveFilter. idName = ', idName);
126
+ console.warn('onRemoveFilter. ids = ', ids);
123
127
  if (ids.length > 0) {
124
128
  filtersAppliedQty++;
129
+ query.whereIn(idName, ids);
125
130
  }
126
131
  if (hasStatus === true) {
127
132
  filtersAppliedQty++;
@@ -418,15 +423,16 @@ class BaseGateway {
418
423
  return result;
419
424
  }
420
425
  async remove(where) {
421
- const { hardRemove } = this.config || {};
426
+ const { hardRemove, hasRemovedAt } = this.config || {};
422
427
  const query = this.getBuilder();
423
- if (hardRemove) {
428
+ if (hardRemove || !hasRemovedAt) {
424
429
  query.delete(this.config.returnFields);
425
430
  }
426
431
  else {
427
432
  const object = await this.transformOnRemove();
428
433
  query.update(object).returning(this.config.returnFields);
429
434
  }
435
+ console.warn('gw.remove returnFields', this.config.returnFields);
430
436
  const filtersAppliedQty = await this.onRemoveFilter(query, where);
431
437
  if (filtersAppliedQty == null || filtersAppliedQty <= 0) {
432
438
  throw new Error(`Failed to remove records in the table '${this.config.table}' as none of filters applied: ${JSON.stringify(where, null, 2)}`);
@@ -106,6 +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
+ console.warn('onRemoveFilter', filterParams);
109
110
  let filtersAppliedQty = 1;
110
111
  const idName = this.getIdFieldUpdateRemove();
111
112
  const ids = [];
@@ -114,8 +115,12 @@ class BaseGateway {
114
115
  ids.push(filter[idName]);
115
116
  }
116
117
  }
118
+ console.warn('onRemoveFilter. arr = ', arr);
119
+ console.warn('onRemoveFilter. idName = ', idName);
120
+ console.warn('onRemoveFilter. ids = ', ids);
117
121
  if (ids.length > 0) {
118
122
  filtersAppliedQty++;
123
+ query.whereIn(idName, ids);
119
124
  }
120
125
  if (hasStatus === true) {
121
126
  filtersAppliedQty++;
@@ -412,15 +417,16 @@ class BaseGateway {
412
417
  return result;
413
418
  }
414
419
  async remove(where) {
415
- const { hardRemove } = this.config || {};
420
+ const { hardRemove, hasRemovedAt } = this.config || {};
416
421
  const query = this.getBuilder();
417
- if (hardRemove) {
422
+ if (hardRemove || !hasRemovedAt) {
418
423
  query.delete(this.config.returnFields);
419
424
  }
420
425
  else {
421
426
  const object = await this.transformOnRemove();
422
427
  query.update(object).returning(this.config.returnFields);
423
428
  }
429
+ console.warn('gw.remove returnFields', this.config.returnFields);
424
430
  const filtersAppliedQty = await this.onRemoveFilter(query, where);
425
431
  if (filtersAppliedQty == null || filtersAppliedQty <= 0) {
426
432
  throw new Error(`Failed to remove records in the table '${this.config.table}' as none of filters applied: ${JSON.stringify(where, null, 2)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdflc/backend-helpers",
3
- "version": "1.0.89",
3
+ "version": "1.0.90",
4
4
  "description": "Set of helper functions and classes to simplify building backend apps within @sdflc ecosystem",
5
5
  "type": "commonjs",
6
6
  "exports": {