c2-mongoose 2.1.288 → 2.1.289
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 +21 -11
- package/package.json +1 -1
- package/src/flow/SearcherFlow.ts +17 -3
|
@@ -360,33 +360,43 @@ 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
|
-
var
|
|
363
|
+
for (var _b = 0, _c = objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or; _b < _c.length; _b++) {
|
|
364
|
+
var clauseOr = _c[_b];
|
|
364
365
|
if (clauseOr.and && Array.isArray(clauseOr.and)) {
|
|
365
|
-
var
|
|
366
|
-
|
|
367
|
-
var
|
|
366
|
+
var and = [];
|
|
367
|
+
var _loop_1 = function (clauseAnd) {
|
|
368
|
+
var conditionsAnd;
|
|
368
369
|
Object.entries(clauseAnd).forEach(function (_a) {
|
|
369
370
|
var key = _a[0], value = _a[1];
|
|
370
371
|
if ((0, Utils_1.isEmpty)(value))
|
|
371
372
|
return;
|
|
372
373
|
value = _this.normalizeValue(key, value);
|
|
373
374
|
var condition = _this.buildCondition(key, value);
|
|
374
|
-
|
|
375
|
+
if (!conditionsAnd) {
|
|
376
|
+
conditionsAnd = {};
|
|
377
|
+
}
|
|
378
|
+
conditionsAnd = __assign(__assign({}, conditionsAnd), { condition: condition });
|
|
375
379
|
});
|
|
380
|
+
if (conditionsAnd) {
|
|
381
|
+
and.push({ $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.length) {
|
|
389
|
+
orPayload.push(and);
|
|
376
390
|
}
|
|
377
|
-
orPayload.push(and_1);
|
|
378
391
|
}
|
|
379
|
-
};
|
|
380
|
-
for (var _b = 0, _c = objectSearch === null || objectSearch === void 0 ? void 0 : objectSearch.or; _b < _c.length; _b++) {
|
|
381
|
-
var clauseOr = _c[_b];
|
|
382
|
-
_loop_1(clauseOr);
|
|
383
392
|
}
|
|
384
393
|
}
|
|
394
|
+
console.log(orPayload);
|
|
385
395
|
var filtersFinal = __assign({}, andQueriesParam);
|
|
386
396
|
if (orPayload.length > 0) {
|
|
387
397
|
if (!filtersFinal.$or)
|
|
388
398
|
filtersFinal.$or = [];
|
|
389
|
-
filtersFinal.$or = __spreadArray(__spreadArray([], filtersFinal.$or, true),
|
|
399
|
+
filtersFinal.$or = __spreadArray(__spreadArray([], filtersFinal.$or, true), orPayload, true);
|
|
390
400
|
}
|
|
391
401
|
return filtersFinal;
|
|
392
402
|
};
|
package/package.json
CHANGED
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -350,23 +350,37 @@ class SearcherFlow<D> {
|
|
|
350
350
|
if (clauseOr.and && Array.isArray(clauseOr.and)) {
|
|
351
351
|
const and: any[] = []
|
|
352
352
|
for (const clauseAnd of clauseOr.and) {
|
|
353
|
+
let conditionsAnd: any
|
|
353
354
|
Object.entries(clauseAnd).forEach(([key, value]) => {
|
|
354
355
|
if (isEmpty(value)) return
|
|
355
356
|
value = this.normalizeValue(key, value)
|
|
356
357
|
const condition = this.buildCondition(key, value)
|
|
357
|
-
|
|
358
|
+
|
|
359
|
+
if (!conditionsAnd) {
|
|
360
|
+
conditionsAnd = {}
|
|
361
|
+
}
|
|
362
|
+
conditionsAnd = { ...conditionsAnd, condition }
|
|
358
363
|
})
|
|
364
|
+
|
|
365
|
+
if (conditionsAnd) {
|
|
366
|
+
and.push({ $and: conditionsAnd })
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (and.length) {
|
|
371
|
+
orPayload.push(and)
|
|
359
372
|
}
|
|
360
|
-
orPayload.push(and)
|
|
361
373
|
}
|
|
362
374
|
}
|
|
363
375
|
}
|
|
364
376
|
|
|
377
|
+
console.log(orPayload)
|
|
378
|
+
|
|
365
379
|
let filtersFinal = { ...andQueriesParam } as any
|
|
366
380
|
|
|
367
381
|
if (orPayload.length > 0) {
|
|
368
382
|
if (!filtersFinal.$or) filtersFinal.$or = []
|
|
369
|
-
filtersFinal.$or = [...filtersFinal.$or,
|
|
383
|
+
filtersFinal.$or = [...filtersFinal.$or, ...orPayload]
|
|
370
384
|
}
|
|
371
385
|
|
|
372
386
|
|