c2-mongoose 2.1.279 → 2.1.280

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.
@@ -357,23 +357,25 @@ var SearcherFlow = /** @class */ (function () {
357
357
  }
358
358
  if (filters.$and.length === 0)
359
359
  delete filters['$and'];
360
- Object.entries(objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or).forEach(function (_a) {
361
- var key = _a[0], value = _a[1];
362
- console.log(key, value);
363
- if ((0, Utils_1.isEmpty)(value))
364
- return;
365
- if (typeof value === 'string' && _this.isValidObjectId(value) && key !== 'owner') {
366
- value = new mongoose_1.Types.ObjectId(value);
367
- }
368
- if (value === 'true') {
369
- value = true;
370
- }
371
- if (value === 'false') {
372
- value = false;
373
- }
374
- var condition = _this.buildCondition(key, value);
375
- filters.$or.push(condition);
376
- });
360
+ if (objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or) {
361
+ Object.entries(objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or).forEach(function (_a) {
362
+ var key = _a[0], value = _a[1];
363
+ console.log(key, value);
364
+ if ((0, Utils_1.isEmpty)(value))
365
+ return;
366
+ if (typeof value === 'string' && _this.isValidObjectId(value) && key !== 'owner') {
367
+ value = new mongoose_1.Types.ObjectId(value);
368
+ }
369
+ if (value === 'true') {
370
+ value = true;
371
+ }
372
+ if (value === 'false') {
373
+ value = false;
374
+ }
375
+ var condition = _this.buildCondition(key, value);
376
+ filters.$or.push(condition);
377
+ });
378
+ }
377
379
  return filters;
378
380
  };
379
381
  SearcherFlow.prototype.isValidObjectId = function (value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.279",
3
+ "version": "2.1.280",
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",
@@ -343,26 +343,28 @@ class SearcherFlow<D> {
343
343
  if (filters.$and.length === 0)
344
344
  delete filters['$and']
345
345
 
346
+ if (objectSearch?.or) {
347
+ Object.entries(objectSearch?.or).forEach(([key, value]) => {
348
+ console.log(key, value)
349
+ if (isEmpty(value)) return
350
+
351
+ if (typeof value === 'string' && this.isValidObjectId(value as string) && key !== 'owner') {
352
+ value = new Types.ObjectId(value as string)
353
+ }
354
+
355
+ if (value === 'true') {
356
+ value = true
357
+ }
358
+
359
+ if (value === 'false') {
360
+ value = false
361
+ }
362
+
363
+ const condition = this.buildCondition(key, value)
364
+ filters.$or.push(condition)
365
+ })
366
+ }
346
367
 
347
- Object.entries(objectSearch?.or).forEach(([key, value]) => {
348
- console.log(key, value)
349
- if (isEmpty(value)) return
350
-
351
- if (typeof value === 'string' && this.isValidObjectId(value as string) && key !== 'owner') {
352
- value = new Types.ObjectId(value as string)
353
- }
354
-
355
- if (value === 'true') {
356
- value = true
357
- }
358
-
359
- if (value === 'false') {
360
- value = false
361
- }
362
-
363
- const condition = this.buildCondition(key, value)
364
- filters.$or.push(condition)
365
- })
366
368
 
367
369
  return filters
368
370
  }