c2-mongoose 2.1.311 → 2.1.313

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.
@@ -113,13 +113,13 @@ var SearcherFlow = /** @class */ (function () {
113
113
  if ((0, Utils_1.isNotEmpty)(options.unions)) {
114
114
  stagesPaging.push.apply(stagesPaging, options.unions);
115
115
  }
116
- if ((0, Utils_1.isEmpty)(options.paging) && this.pageable) {
116
+ if ((0, Utils_1.isEmpty)(options.paging)) {
117
117
  stagesPaging.push({ $match: this.filters });
118
118
  stagesPaging = __spreadArray(__spreadArray([], stagesItems, true), this.buildPaginationData(), true);
119
119
  }
120
- // else {
121
- // stagesPaging = [...stagesPaging, ...options.paging]
122
- // }
120
+ else {
121
+ stagesPaging = __spreadArray(__spreadArray([], stagesPaging, true), options.paging, true);
122
+ }
123
123
  if (this.pageable === true) {
124
124
  stagesItems.push({ $skip: ((this.page - 1) * this.limit) || 0 });
125
125
  stagesItems.push({ $limit: this.limit });
@@ -247,6 +247,10 @@ var SearcherFlow = /** @class */ (function () {
247
247
  key = key.replace("IsEmpty", "");
248
248
  condition[key] = value ? { $size: 0 } : { $not: { $size: 0 } };
249
249
  }
250
+ else if (key.endsWith("AtLeastOne")) {
251
+ key = key.replace("AtLeastOne", "");
252
+ condition[key] = { $elemMatch: value };
253
+ }
250
254
  else {
251
255
  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') {
252
256
  if (!Array.isArray(value)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.311",
3
+ "version": "2.1.313",
4
4
  "description": "Lib to make any search in database mongoose and use as basic crud",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -77,13 +77,12 @@ class SearcherFlow<D> {
77
77
  }
78
78
 
79
79
 
80
- if (isEmpty(options.paging) && this.pageable) {
80
+ if (isEmpty(options.paging)) {
81
81
  stagesPaging.push({ $match: this.filters })
82
82
  stagesPaging = [...stagesItems, ...this.buildPaginationData()]
83
- }
84
- // else {
85
- // stagesPaging = [...stagesPaging, ...options.paging]
86
- // }
83
+ } else {
84
+ stagesPaging = [...stagesPaging, ...options.paging]
85
+ }
87
86
 
88
87
  if (this.pageable === true) {
89
88
  stagesItems.push({ $skip: ((this.page - 1) * this.limit) || 0 })
@@ -223,6 +222,9 @@ class SearcherFlow<D> {
223
222
  } else if (key.endsWith("IsEmpty")) {
224
223
  key = key.replace("IsEmpty", "");
225
224
  condition[key] = value ? { $size: 0 } : { $not: { $size: 0 } };
225
+ } else if (key.endsWith("AtLeastOne")) {
226
+ key = key.replace("AtLeastOne", "");
227
+ condition[key] = { $elemMatch: value }
226
228
  } else {
227
229
  if (this.model?.schema?.paths[key]?.instance === 'Array') {
228
230
  if (!Array.isArray(value)) {