c2-mongoose 2.1.291 → 2.1.293

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.
@@ -360,35 +360,35 @@ var SearcherFlow = /** @class */ (function () {
360
360
  // delete filters['$and']
361
361
  var orPayload = [];
362
362
  if (objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or) {
363
- for (var _b = 0, _c = objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or; _b < _c.length; _b++) {
364
- var clauseOr = _c[_b];
365
- if (clauseOr.and && Array.isArray(clauseOr.and)) {
366
- var and = void 0;
367
- var _loop_1 = function (clauseAnd) {
368
- var conditionsAnd;
369
- Object.entries(clauseAnd).forEach(function (_a) {
370
- var key = _a[0], value = _a[1];
371
- if ((0, Utils_1.isEmpty)(value))
372
- return;
373
- value = _this.normalizeValue(key, value);
374
- var condition = _this.buildCondition(key, value);
375
- if (!conditionsAnd) {
376
- conditionsAnd = {};
377
- }
378
- conditionsAnd = __assign(__assign({}, conditionsAnd), condition);
379
- });
380
- if (conditionsAnd) {
381
- and = { $and: conditionsAnd };
382
- }
383
- };
384
- for (var _d = 0, _e = clauseOr.and; _d < _e.length; _d++) {
385
- var clauseAnd = _e[_d];
386
- _loop_1(clauseAnd);
387
- }
388
- if (and) {
389
- orPayload.push(and);
363
+ var _loop_1 = function (clauseOr) {
364
+ // if (clauseOr.and && Array.isArray(clauseOr.and)) {
365
+ var and
366
+ // for (const clauseAnd of clauseOr.and) {
367
+ = void 0;
368
+ // for (const clauseAnd of clauseOr.and) {
369
+ var conditionsAnd;
370
+ Object.entries(clauseOr).forEach(function (_a) {
371
+ var key = _a[0], value = _a[1];
372
+ if ((0, Utils_1.isEmpty)(value))
373
+ return;
374
+ value = _this.normalizeValue(key, value);
375
+ var condition = _this.buildCondition(key, value);
376
+ if (!conditionsAnd) {
377
+ conditionsAnd = {};
390
378
  }
379
+ conditionsAnd = __assign(__assign({}, conditionsAnd), condition);
380
+ });
381
+ if (conditionsAnd) {
382
+ and = { $and: [conditionsAnd] };
383
+ }
384
+ // }
385
+ if (and) {
386
+ orPayload.push(and);
391
387
  }
388
+ };
389
+ for (var _b = 0, _c = objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or; _b < _c.length; _b++) {
390
+ var clauseOr = _c[_b];
391
+ _loop_1(clauseOr);
392
392
  }
393
393
  }
394
394
  console.log(orPayload);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.291",
3
+ "version": "2.1.293",
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",
@@ -347,30 +347,30 @@ class SearcherFlow<D> {
347
347
  const orPayload: any[] = []
348
348
  if (objectSearch?.or) {
349
349
  for (const clauseOr of objectSearch?.or) {
350
- if (clauseOr.and && Array.isArray(clauseOr.and)) {
351
- let and: any
352
- for (const clauseAnd of clauseOr.and) {
353
- let conditionsAnd: any
354
- Object.entries(clauseAnd).forEach(([key, value]) => {
355
- if (isEmpty(value)) return
356
- value = this.normalizeValue(key, value)
357
- const condition = this.buildCondition(key, value)
358
-
359
- if (!conditionsAnd) {
360
- conditionsAnd = {}
361
- }
362
- conditionsAnd = { ...conditionsAnd, ...condition }
363
- })
364
-
365
- if (conditionsAnd) {
366
- and = { $and: conditionsAnd }
367
- }
350
+ // if (clauseOr.and && Array.isArray(clauseOr.and)) {
351
+ let and: any
352
+ // for (const clauseAnd of clauseOr.and) {
353
+ let conditionsAnd: any
354
+ Object.entries(clauseOr).forEach(([key, value]) => {
355
+ if (isEmpty(value)) return
356
+ value = this.normalizeValue(key, value)
357
+ const condition = this.buildCondition(key, value)
358
+
359
+ if (!conditionsAnd) {
360
+ conditionsAnd = {}
368
361
  }
362
+ conditionsAnd = { ...conditionsAnd, ...condition }
363
+ })
369
364
 
370
- if (and) {
371
- orPayload.push(and)
372
- }
365
+ if (conditionsAnd) {
366
+ and = { $and: [conditionsAnd] }
367
+ }
368
+ // }
369
+
370
+ if (and) {
371
+ orPayload.push(and)
373
372
  }
373
+ // }
374
374
  }
375
375
  }
376
376