c2-mongoose 2.1.301 → 2.1.303
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.
|
@@ -259,6 +259,10 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
259
259
|
var fieldName = key.replace('Exists', '');
|
|
260
260
|
condition[fieldName] = { $exists: value };
|
|
261
261
|
}
|
|
262
|
+
else if (key.endsWith("IsEmpty")) {
|
|
263
|
+
key = key.replace("IsEmpty", "");
|
|
264
|
+
condition[key] = { $size: value ? 0 : { $gte: 1 } };
|
|
265
|
+
}
|
|
262
266
|
else {
|
|
263
267
|
if (((_c = (_b = (_a = this.model) === null || _a === void 0 ? void 0 : _a.schema) === null || _b === void 0 ? void 0 : _b.paths[key]) === null || _c === void 0 ? void 0 : _c.instance) === 'Array') {
|
|
264
268
|
if (!Array.isArray(value)) {
|
|
@@ -279,7 +283,7 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
279
283
|
}
|
|
280
284
|
else if (key.endsWith("IsEmpty")) {
|
|
281
285
|
key = key.replace("IsEmpty", "");
|
|
282
|
-
condition[key] = { $size: 0 };
|
|
286
|
+
condition[key] = { $size: value ? 0 : { $gte: 1 } };
|
|
283
287
|
}
|
|
284
288
|
else {
|
|
285
289
|
condition[key] = { $in: value };
|
package/package.json
CHANGED
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -236,6 +236,9 @@ class SearcherFlow<D> {
|
|
|
236
236
|
} else if (key.endsWith('Exists')) {
|
|
237
237
|
var fieldName = key.replace('Exists', '')
|
|
238
238
|
condition[fieldName] = { $exists: value as boolean }
|
|
239
|
+
} else if (key.endsWith("IsEmpty")) {
|
|
240
|
+
key = key.replace("IsEmpty", "");
|
|
241
|
+
condition[key] = { $size: value ? 0 : { $gte: 1 } };
|
|
239
242
|
} else {
|
|
240
243
|
if (this.model?.schema?.paths[key]?.instance === 'Array') {
|
|
241
244
|
if (!Array.isArray(value)) {
|
|
@@ -256,7 +259,7 @@ class SearcherFlow<D> {
|
|
|
256
259
|
condition[key] = { $nin: value };
|
|
257
260
|
} else if (key.endsWith("IsEmpty")) {
|
|
258
261
|
key = key.replace("IsEmpty", "");
|
|
259
|
-
condition[key] = { $size: 0 };
|
|
262
|
+
condition[key] = { $size: value ? 0 : { $gte: 1 } };
|
|
260
263
|
} else {
|
|
261
264
|
condition[key] = { $in: value };
|
|
262
265
|
}
|