c2-mongoose 2.1.292 → 2.1.294
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 +27 -28
- package/package.json +1 -1
- package/src/flow/SearcherFlow.ts +21 -23
|
@@ -360,38 +360,37 @@ 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
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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
|
-
console.log(orPayload);
|
|
395
394
|
var filtersFinal = __assign({}, andQueriesParam);
|
|
396
395
|
if (orPayload.length > 0) {
|
|
397
396
|
if (!filtersFinal.$or)
|
package/package.json
CHANGED
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -347,35 +347,33 @@ 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
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
365
|
+
if (conditionsAnd) {
|
|
366
|
+
and = { $and: [conditionsAnd] }
|
|
373
367
|
}
|
|
368
|
+
// }
|
|
369
|
+
|
|
370
|
+
if (and) {
|
|
371
|
+
orPayload.push(and)
|
|
372
|
+
}
|
|
373
|
+
// }
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
|
|
377
|
-
console.log(orPayload)
|
|
378
|
-
|
|
379
377
|
let filtersFinal = { ...andQueriesParam } as any
|
|
380
378
|
|
|
381
379
|
if (orPayload.length > 0) {
|