c2-mongoose 2.1.284 → 2.1.285

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.
@@ -359,23 +359,26 @@ var SearcherFlow = /** @class */ (function () {
359
359
  // delete filters['$and']
360
360
  var orPayload = [];
361
361
  if (objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or) {
362
- var _loop_1 = function (clause) {
363
- if (clause.and && Array.isArray(clause.and)) {
364
- var clauseAnd_1 = [];
365
- Object.entries(clause.and).forEach(function (_a) {
366
- var key = _a[0], value = _a[1];
367
- if ((0, Utils_1.isEmpty)(value))
368
- return;
369
- value = _this.normalizeValue(key, value);
370
- var condition = _this.buildCondition(key, value);
371
- clauseAnd_1.push(condition);
372
- });
373
- orPayload.push(clauseAnd_1);
362
+ var _loop_1 = function (clauseOr) {
363
+ if (clauseOr.and && Array.isArray(clauseOr.and)) {
364
+ var and_1 = [];
365
+ for (var _d = 0, _e = clauseOr.and; _d < _e.length; _d++) {
366
+ var clauseAnd = _e[_d];
367
+ Object.entries(clauseAnd).forEach(function (_a) {
368
+ var key = _a[0], value = _a[1];
369
+ if ((0, Utils_1.isEmpty)(value))
370
+ return;
371
+ value = _this.normalizeValue(key, value);
372
+ var condition = _this.buildCondition(key, value);
373
+ and_1.push(condition);
374
+ });
375
+ }
376
+ orPayload.push(and_1);
374
377
  }
375
378
  };
376
379
  for (var _b = 0, _c = objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or; _b < _c.length; _b++) {
377
- var clause = _c[_b];
378
- _loop_1(clause);
380
+ var clauseOr = _c[_b];
381
+ _loop_1(clauseOr);
379
382
  }
380
383
  }
381
384
  var filtersFinal = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.284",
3
+ "version": "2.1.285",
4
4
  "description": "Lib to make any search in database mongoose and use as basic crud",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -345,17 +345,18 @@ class SearcherFlow<D> {
345
345
 
346
346
  const orPayload: any[] = []
347
347
  if (objectSearch?.or) {
348
- for (const clause of objectSearch?.or) {
349
- if (clause.and && Array.isArray(clause.and)) {
350
- const clauseAnd: any[] = []
351
- Object.entries(clause.and).forEach(([key, value]) => {
352
- if (isEmpty(value)) return
353
- value = this.normalizeValue(key, value)
354
- const condition = this.buildCondition(key, value)
355
- clauseAnd.push(condition)
356
- })
357
-
358
- orPayload.push(clauseAnd)
348
+ for (const clauseOr of objectSearch?.or) {
349
+ if (clauseOr.and && Array.isArray(clauseOr.and)) {
350
+ const and: any[] = []
351
+ for (const clauseAnd of clauseOr.and) {
352
+ Object.entries(clauseAnd).forEach(([key, value]) => {
353
+ if (isEmpty(value)) return
354
+ value = this.normalizeValue(key, value)
355
+ const condition = this.buildCondition(key, value)
356
+ and.push(condition)
357
+ })
358
+ }
359
+ orPayload.push(and)
359
360
  }
360
361
  }
361
362
  }