c2-mongoose 2.1.83 → 2.1.85

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.
@@ -195,13 +195,14 @@ var SearchFlow = /** @class */ (function () {
195
195
  return __generator(this, function (_c) {
196
196
  switch (_c.label) {
197
197
  case 0:
198
- stagesItems = __spreadArray([
198
+ stagesItems = __spreadArray(__spreadArray([
199
199
  { $match: this.filters },
200
+ this.projection ? { $project: this.projection } : { $addFields: {} }
201
+ ], options.pipelines, true), [
200
202
  { $sort: this.sort },
201
203
  { $skip: ((this.page - 1) * this.limit) || 0 },
202
204
  { $limit: this.limit },
203
- this.projection ? { $project: this.projection } : { $addFields: {} }
204
- ], options.pipelines, true);
205
+ ], false);
205
206
  return [4 /*yield*/, model.aggregate([
206
207
  {
207
208
  $facet: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.83",
3
+ "version": "2.1.85",
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",
@@ -120,11 +120,11 @@ abstract class SearchFlow {
120
120
  async searchPageable(model: mongoose.Model<any>, options: SearchOptions) {
121
121
  let stagesItems = [
122
122
  { $match: this.filters },
123
+ this.projection ? { $project: this.projection } : { $addFields: {} },
124
+ ...options.pipelines,
123
125
  { $sort: this.sort },
124
126
  { $skip: ((this.page - 1) * this.limit) || 0 },
125
127
  { $limit: this.limit },
126
- this.projection ? { $project: this.projection } : { $addFields: {} },
127
- ...options.pipelines
128
128
  ]
129
129
 
130
130
  const result = await model.aggregate(