c2-mongoose 2.1.313 → 2.1.315
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.
|
@@ -196,8 +196,9 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
196
196
|
return fieldsTyped;
|
|
197
197
|
};
|
|
198
198
|
SearcherFlow.prototype.buildCondition = function (key, value) {
|
|
199
|
+
var _a;
|
|
199
200
|
var _this = this;
|
|
200
|
-
var
|
|
201
|
+
var _b, _c, _d;
|
|
201
202
|
var condition = {};
|
|
202
203
|
if (key.endsWith('DateRange')) {
|
|
203
204
|
var fieldName = key.replace('Range', '');
|
|
@@ -247,12 +248,17 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
247
248
|
key = key.replace("IsEmpty", "");
|
|
248
249
|
condition[key] = value ? { $size: 0 } : { $not: { $size: 0 } };
|
|
249
250
|
}
|
|
250
|
-
else if (key.endsWith("
|
|
251
|
-
key = key.replace("
|
|
252
|
-
|
|
251
|
+
else if (key.endsWith("AtLeastOneExists")) {
|
|
252
|
+
key = key.replace("AtLeastOneExists", "");
|
|
253
|
+
var fields = key.split('.');
|
|
254
|
+
if (!fields)
|
|
255
|
+
return condition;
|
|
256
|
+
// const elemMatch = {} as any
|
|
257
|
+
// elemMatch[lastField] = value as boolean
|
|
258
|
+
condition[fields[0]] = { $elemMatch: (_a = {}, _a[fields[1]] = value, _a) };
|
|
253
259
|
}
|
|
254
260
|
else {
|
|
255
|
-
if (((
|
|
261
|
+
if (((_d = (_c = (_b = this.model) === null || _b === void 0 ? void 0 : _b.schema) === null || _c === void 0 ? void 0 : _c.paths[key]) === null || _d === void 0 ? void 0 : _d.instance) === 'Array') {
|
|
256
262
|
if (!Array.isArray(value)) {
|
|
257
263
|
value = [value];
|
|
258
264
|
}
|
package/package.json
CHANGED
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -222,9 +222,15 @@ class SearcherFlow<D> {
|
|
|
222
222
|
} else if (key.endsWith("IsEmpty")) {
|
|
223
223
|
key = key.replace("IsEmpty", "");
|
|
224
224
|
condition[key] = value ? { $size: 0 } : { $not: { $size: 0 } };
|
|
225
|
-
} else if (key.endsWith("
|
|
226
|
-
key = key.replace("
|
|
227
|
-
|
|
225
|
+
} else if (key.endsWith("AtLeastOneExists")) {
|
|
226
|
+
key = key.replace("AtLeastOneExists", "");
|
|
227
|
+
|
|
228
|
+
const fields = key.split('.')
|
|
229
|
+
if (!fields) return condition;
|
|
230
|
+
|
|
231
|
+
// const elemMatch = {} as any
|
|
232
|
+
// elemMatch[lastField] = value as boolean
|
|
233
|
+
condition[fields[0]] = { $elemMatch: { [fields[1]]: value as boolean} }
|
|
228
234
|
} else {
|
|
229
235
|
if (this.model?.schema?.paths[key]?.instance === 'Array') {
|
|
230
236
|
if (!Array.isArray(value)) {
|