c2-mongoose 2.1.75 → 2.1.76

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,7 +195,7 @@ var SearchFlow = /** @class */ (function () {
195
195
  stagesItems = __spreadArray([
196
196
  { $match: this.filters },
197
197
  { $sort: this.sort },
198
- { $skip: (this.page - 1) * this.limit },
198
+ { $skip: ((this.page - 1) * this.limit) || 0 },
199
199
  { $limit: this.limit },
200
200
  this.projection ? { $project: this.projection } : { $addFields: {} }
201
201
  ], options.pipelines, true);
@@ -208,7 +208,7 @@ var SearchFlow = /** @class */ (function () {
208
208
  { $count: "total" },
209
209
  {
210
210
  $addFields: {
211
- page: this.page,
211
+ page: this.page || 1,
212
212
  limit: this.limit
213
213
  }
214
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.75",
3
+ "version": "2.1.76",
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",
@@ -119,7 +119,7 @@ abstract class SearchFlow {
119
119
  let stagesItems = [
120
120
  { $match: this.filters },
121
121
  { $sort: this.sort },
122
- { $skip: (this.page - 1) * this.limit },
122
+ { $skip: ((this.page - 1) * this.limit) || 0 },
123
123
  { $limit: this.limit },
124
124
  this.projection ? { $project: this.projection } : { $addFields: {} },
125
125
  ...options.pipelines
@@ -136,7 +136,7 @@ abstract class SearchFlow {
136
136
  {
137
137
  $addFields:
138
138
  {
139
- page: this.page,
139
+ page: this.page || 1,
140
140
  limit: this.limit
141
141
  }
142
142
  }