c2-mongoose 2.1.286 → 2.1.288

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.
@@ -304,7 +304,7 @@ var SearcherFlow = /** @class */ (function () {
304
304
  var _this = this;
305
305
  // Recuperar todos os campos do tipo String
306
306
  var camposString = (0, Utils_1.isEmpty)(this.searchTextFields) ? this.extractFieldsOfType(this.model.schema, 'String') : this.searchTextFields;
307
- var andQueriesParam = [];
307
+ var andQueriesParam = {};
308
308
  Object.entries(objectSearch).forEach(function (_a) {
309
309
  var key = _a[0], value = _a[1];
310
310
  if ((0, Utils_1.isNotEmpty)(value) || value === null) {
@@ -341,7 +341,7 @@ var SearcherFlow = /** @class */ (function () {
341
341
  value = false;
342
342
  }
343
343
  var condition = _this.buildCondition(key, value);
344
- andQueriesParam.push(condition);
344
+ andQueriesParam = __assign(__assign({}, andQueriesParam), condition);
345
345
  }
346
346
  });
347
347
  if ((0, Utils_1.isNotEmpty)(this.searchText) && (0, Utils_1.isNotEmpty)(camposString)) {
@@ -353,7 +353,8 @@ var SearcherFlow = /** @class */ (function () {
353
353
  conditionAux[fieldString] = { $regex: regex };
354
354
  conditions.$or.push(conditionAux);
355
355
  }
356
- andQueriesParam.push(conditions);
356
+ // andQueriesParam.push(conditions)
357
+ andQueriesParam = __assign(__assign({}, andQueriesParam), conditions);
357
358
  }
358
359
  // if (filters.$and.length === 0)
359
360
  // delete filters['$and']
@@ -381,11 +382,7 @@ var SearcherFlow = /** @class */ (function () {
381
382
  _loop_1(clauseOr);
382
383
  }
383
384
  }
384
- var filtersFinal = {};
385
- if (andQueriesParam.length > 0) {
386
- // if (!filtersFinal.$or) filtersFinal.$or = []
387
- filtersFinal = __assign(__assign({}, filtersFinal), andQueriesParam);
388
- }
385
+ var filtersFinal = __assign({}, andQueriesParam);
389
386
  if (orPayload.length > 0) {
390
387
  if (!filtersFinal.$or)
391
388
  filtersFinal.$or = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.286",
3
+ "version": "2.1.288",
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",
@@ -285,7 +285,7 @@ class SearcherFlow<D> {
285
285
  const camposString = isEmpty(this.searchTextFields) ? this.extractFieldsOfType(this.model.schema, 'String') : this.searchTextFields
286
286
 
287
287
 
288
- const andQueriesParam = []
288
+ let andQueriesParam = {} as any
289
289
  Object.entries(objectSearch).forEach(([key, value]) => {
290
290
  if (isNotEmpty(value) || value === null) {
291
291
  if ([
@@ -324,7 +324,7 @@ class SearcherFlow<D> {
324
324
  }
325
325
 
326
326
  const condition = this.buildCondition(key, value)
327
- andQueriesParam.push(condition)
327
+ andQueriesParam = { ...andQueriesParam, ...condition }
328
328
  }
329
329
  })
330
330
 
@@ -337,7 +337,8 @@ class SearcherFlow<D> {
337
337
 
338
338
  conditions.$or.push(conditionAux)
339
339
  }
340
- andQueriesParam.push(conditions)
340
+ // andQueriesParam.push(conditions)
341
+ andQueriesParam = { ...andQueriesParam, ...conditions }
341
342
  }
342
343
 
343
344
  // if (filters.$and.length === 0)
@@ -361,11 +362,7 @@ class SearcherFlow<D> {
361
362
  }
362
363
  }
363
364
 
364
- let filtersFinal = {} as any
365
- if (andQueriesParam.length > 0) {
366
- // if (!filtersFinal.$or) filtersFinal.$or = []
367
- filtersFinal = { ...filtersFinal, ...andQueriesParam }
368
- }
365
+ let filtersFinal = { ...andQueriesParam } as any
369
366
 
370
367
  if (orPayload.length > 0) {
371
368
  if (!filtersFinal.$or) filtersFinal.$or = []