c2-mongoose 2.1.51 → 2.1.52

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.
@@ -145,10 +145,11 @@ var SearchFlow = /** @class */ (function () {
145
145
  return new RegExp("".concat(regexExpression), 'i');
146
146
  };
147
147
  SearchFlow.prototype.searchPageable = function (model, pipeline) {
148
+ var _a;
148
149
  return __awaiter(this, void 0, void 0, function () {
149
150
  var stagesItems, result;
150
- return __generator(this, function (_a) {
151
- switch (_a.label) {
151
+ return __generator(this, function (_b) {
152
+ switch (_b.label) {
152
153
  case 0:
153
154
  stagesItems = __spreadArray([
154
155
  { $match: this.filters },
@@ -174,10 +175,10 @@ var SearchFlow = /** @class */ (function () {
174
175
  }
175
176
  ])];
176
177
  case 1:
177
- result = _a.sent();
178
+ result = _b.sent();
178
179
  return [2 /*return*/, {
179
180
  items: result[0].items,
180
- paging: result[0].paging[0]
181
+ paging: ((_a = result[0]) === null || _a === void 0 ? void 0 : _a.paging[0]) || { total: 0, page: 1, limit: this.limit }
181
182
  }];
182
183
  }
183
184
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.51",
3
+ "version": "2.1.52",
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",
@@ -105,7 +105,7 @@ abstract class SearchFlow {
105
105
  )
106
106
  return {
107
107
  items: result[0].items,
108
- paging: result[0].paging[0]
108
+ paging: result[0]?.paging[0] || { total: 0, page: 1, limit: this.limit }
109
109
  }
110
110
  }
111
111