c2-mongoose 2.1.126 → 2.1.128

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.
@@ -161,16 +161,17 @@ var SearchFlow = /** @class */ (function () {
161
161
  return __generator(this, function (_d) {
162
162
  switch (_d.label) {
163
163
  case 0:
164
- stagesItems = [{ $match: this.filters }];
164
+ stagesItems = [];
165
+ if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
166
+ stagesItems.push.apply(stagesItems, options.pipelines);
167
+ }
168
+ stagesItems.push({ $match: this.filters });
165
169
  if ((0, Utils_1.isNotEmpty)(options.unions)) {
166
170
  stagesItems.push.apply(stagesItems, options.unions);
167
171
  }
168
172
  if ((0, Utils_1.isNotEmpty)(this.projection)) {
169
173
  stagesItems.push({ $project: this.projection });
170
174
  }
171
- if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
172
- stagesItems.push.apply(stagesItems, options.pipelines);
173
- }
174
175
  stagesItems.push({ $sort: this.sort });
175
176
  stagesItems.push({ $limit: (_a = this.limit) !== null && _a !== void 0 ? _a : 50 });
176
177
  stagesMetadata = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.126",
3
+ "version": "2.1.128",
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",
@@ -123,7 +123,14 @@ abstract class SearchFlow {
123
123
 
124
124
  async searchNoPageable(model: mongoose.Model<any>, options: SearchOptions) {
125
125
 
126
- let stagesItems: any[] = [{ $match: this.filters }]
126
+ let stagesItems: any[] = []
127
+
128
+
129
+ if (isNotEmpty(options.pipelines)) {
130
+ stagesItems.push(...options.pipelines)
131
+ }
132
+
133
+ stagesItems.push({ $match: this.filters })
127
134
 
128
135
  if (isNotEmpty(options.unions)) {
129
136
  stagesItems.push(...options.unions)
@@ -133,9 +140,6 @@ abstract class SearchFlow {
133
140
  stagesItems.push({ $project: this.projection })
134
141
  }
135
142
 
136
- if (isNotEmpty(options.pipelines)) {
137
- stagesItems.push(...options.pipelines)
138
- }
139
143
 
140
144
  stagesItems.push({ $sort: this.sort })
141
145
  stagesItems.push({ $limit: this.limit ?? 50 })