c2-mongoose 2.1.315 → 2.1.317
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.
|
@@ -240,6 +240,13 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
240
240
|
var fieldName = key.replace('Like', '');
|
|
241
241
|
condition[fieldName] = this.buildRegex(value); //{ $regex: value as any, $options: 'i' }
|
|
242
242
|
}
|
|
243
|
+
else if (key.endsWith("AtLeastOneExists")) {
|
|
244
|
+
key = key.replace("AtLeastOneExists", "");
|
|
245
|
+
var fields = key.split('.');
|
|
246
|
+
if (!fields)
|
|
247
|
+
return condition;
|
|
248
|
+
condition[fields[0]] = { $elemMatch: (_a = {}, _a[fields[1]] = { $exists: value }, _a) };
|
|
249
|
+
}
|
|
243
250
|
else if (key.endsWith('Exists')) {
|
|
244
251
|
var fieldName = key.replace('Exists', '');
|
|
245
252
|
condition[fieldName] = { $exists: value };
|
|
@@ -248,15 +255,6 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
248
255
|
key = key.replace("IsEmpty", "");
|
|
249
256
|
condition[key] = value ? { $size: 0 } : { $not: { $size: 0 } };
|
|
250
257
|
}
|
|
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) };
|
|
259
|
-
}
|
|
260
258
|
else {
|
|
261
259
|
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') {
|
|
262
260
|
if (!Array.isArray(value)) {
|
package/package.json
CHANGED
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -216,21 +216,19 @@ class SearcherFlow<D> {
|
|
|
216
216
|
} else if (key.endsWith('Like')) {
|
|
217
217
|
var fieldName = key.replace('Like', '')
|
|
218
218
|
condition[fieldName] = this.buildRegex(value as string) //{ $regex: value as any, $options: 'i' }
|
|
219
|
-
} else if (key.endsWith('Exists')) {
|
|
220
|
-
var fieldName = key.replace('Exists', '')
|
|
221
|
-
condition[fieldName] = { $exists: value as boolean }
|
|
222
|
-
} else if (key.endsWith("IsEmpty")) {
|
|
223
|
-
key = key.replace("IsEmpty", "");
|
|
224
|
-
condition[key] = value ? { $size: 0 } : { $not: { $size: 0 } };
|
|
225
219
|
} else if (key.endsWith("AtLeastOneExists")) {
|
|
226
220
|
key = key.replace("AtLeastOneExists", "");
|
|
227
221
|
|
|
228
222
|
const fields = key.split('.')
|
|
229
223
|
if (!fields) return condition;
|
|
230
224
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
225
|
+
condition[fields[0]] = { $elemMatch: { [fields[1]]: { $exists: value as boolean } } }
|
|
226
|
+
} else if (key.endsWith('Exists')) {
|
|
227
|
+
var fieldName = key.replace('Exists', '')
|
|
228
|
+
condition[fieldName] = { $exists: value as boolean }
|
|
229
|
+
} else if (key.endsWith("IsEmpty")) {
|
|
230
|
+
key = key.replace("IsEmpty", "");
|
|
231
|
+
condition[key] = value ? { $size: 0 } : { $not: { $size: 0 } };
|
|
234
232
|
} else {
|
|
235
233
|
if (this.model?.schema?.paths[key]?.instance === 'Array') {
|
|
236
234
|
if (!Array.isArray(value)) {
|