c2-mongoose 2.1.279 → 2.1.281
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.
- package/dist/flow/SearcherFlow.js +19 -18
- package/package.json +1 -1
- package/src/flow/SearcherFlow.ts +21 -20
|
@@ -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 filters = { $and: [] };
|
|
307
|
+
var filters = { $and: [], $or: [] };
|
|
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) {
|
|
@@ -357,23 +357,24 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
357
357
|
}
|
|
358
358
|
if (filters.$and.length === 0)
|
|
359
359
|
delete filters['$and'];
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
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
|
+
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
|
+
});
|
|
377
|
+
}
|
|
377
378
|
return filters;
|
|
378
379
|
};
|
|
379
380
|
SearcherFlow.prototype.isValidObjectId = function (value) {
|
package/package.json
CHANGED
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -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
|
-
let filters = { $and: [] } as any
|
|
288
|
+
let filters = { $and: [], $or: [] } as any
|
|
289
289
|
Object.entries(objectSearch).forEach(([key, value]) => {
|
|
290
290
|
if (isNotEmpty(value) || value === null) {
|
|
291
291
|
if ([
|
|
@@ -343,26 +343,27 @@ 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
|
+
if (isEmpty(value)) return
|
|
349
|
+
|
|
350
|
+
if (typeof value === 'string' && this.isValidObjectId(value as string) && key !== 'owner') {
|
|
351
|
+
value = new Types.ObjectId(value as string)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (value === 'true') {
|
|
355
|
+
value = true
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (value === 'false') {
|
|
359
|
+
value = false
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const condition = this.buildCondition(key, value)
|
|
363
|
+
filters.$or.push(condition)
|
|
364
|
+
})
|
|
365
|
+
}
|
|
346
366
|
|
|
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
367
|
|
|
367
368
|
return filters
|
|
368
369
|
}
|