c2-mongoose 2.1.290 → 2.1.292

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.
@@ -363,7 +363,7 @@ var SearcherFlow = /** @class */ (function () {
363
363
  for (var _b = 0, _c = objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or; _b < _c.length; _b++) {
364
364
  var clauseOr = _c[_b];
365
365
  if (clauseOr.and && Array.isArray(clauseOr.and)) {
366
- var and = [];
366
+ var and = void 0;
367
367
  var _loop_1 = function (clauseAnd) {
368
368
  var conditionsAnd;
369
369
  Object.entries(clauseAnd).forEach(function (_a) {
@@ -378,14 +378,14 @@ var SearcherFlow = /** @class */ (function () {
378
378
  conditionsAnd = __assign(__assign({}, conditionsAnd), condition);
379
379
  });
380
380
  if (conditionsAnd) {
381
- and.push({ $and: conditionsAnd });
381
+ and = { $and: [conditionsAnd] };
382
382
  }
383
383
  };
384
384
  for (var _d = 0, _e = clauseOr.and; _d < _e.length; _d++) {
385
385
  var clauseAnd = _e[_d];
386
386
  _loop_1(clauseAnd);
387
387
  }
388
- if (and.length) {
388
+ if (and) {
389
389
  orPayload.push(and);
390
390
  }
391
391
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.290",
3
+ "version": "2.1.292",
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",
@@ -348,7 +348,7 @@ class SearcherFlow<D> {
348
348
  if (objectSearch?.or) {
349
349
  for (const clauseOr of objectSearch?.or) {
350
350
  if (clauseOr.and && Array.isArray(clauseOr.and)) {
351
- const and: any[] = []
351
+ let and: any
352
352
  for (const clauseAnd of clauseOr.and) {
353
353
  let conditionsAnd: any
354
354
  Object.entries(clauseAnd).forEach(([key, value]) => {
@@ -363,11 +363,11 @@ class SearcherFlow<D> {
363
363
  })
364
364
 
365
365
  if (conditionsAnd) {
366
- and.push({ $and: conditionsAnd })
366
+ and = { $and: [conditionsAnd] }
367
367
  }
368
368
  }
369
369
 
370
- if (and.length) {
370
+ if (and) {
371
371
  orPayload.push(and)
372
372
  }
373
373
  }