c2-mongoose 2.1.312 → 2.1.314
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,8 +248,17 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
247
248
|
key = key.replace("IsEmpty", "");
|
|
248
249
|
condition[key] = value ? { $size: 0 } : { $not: { $size: 0 } };
|
|
249
250
|
}
|
|
251
|
+
else if (key.endsWith("AtLeastOneExists")) {
|
|
252
|
+
key = key.replace("AtLeastOneExists", "");
|
|
253
|
+
var lastField = key.split('.').pop();
|
|
254
|
+
if (!lastField)
|
|
255
|
+
return condition;
|
|
256
|
+
// const elemMatch = {} as any
|
|
257
|
+
// elemMatch[lastField] = value as boolean
|
|
258
|
+
condition[key] = { $elemMatch: (_a = {}, _a[lastField] = value, _a) };
|
|
259
|
+
}
|
|
250
260
|
else {
|
|
251
|
-
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') {
|
|
252
262
|
if (!Array.isArray(value)) {
|
|
253
263
|
value = [value];
|
|
254
264
|
}
|
package/package.json
CHANGED
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -222,6 +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("AtLeastOneExists")) {
|
|
226
|
+
key = key.replace("AtLeastOneExists", "");
|
|
227
|
+
|
|
228
|
+
const lastField = key.split('.').pop()
|
|
229
|
+
if (!lastField) return condition;
|
|
230
|
+
|
|
231
|
+
// const elemMatch = {} as any
|
|
232
|
+
// elemMatch[lastField] = value as boolean
|
|
233
|
+
condition[key] = { $elemMatch: { [lastField]: value as boolean} }
|
|
225
234
|
} else {
|
|
226
235
|
if (this.model?.schema?.paths[key]?.instance === 'Array') {
|
|
227
236
|
if (!Array.isArray(value)) {
|