c2-mongoose 2.1.337 → 2.1.339

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.
@@ -58,13 +58,13 @@ var SearcherV2Flow = /** @class */ (function () {
58
58
  function SearcherV2Flow() {
59
59
  }
60
60
  SearcherV2Flow.prototype.exec = function (params, model) {
61
- var _a, _b;
61
+ var _a, _b, _c;
62
62
  return __awaiter(this, void 0, void 0, function () {
63
63
  var facet, pipelineFacetPaging, pipelineFacetItems, result, ret;
64
- return __generator(this, function (_c) {
65
- switch (_c.label) {
64
+ return __generator(this, function (_d) {
65
+ switch (_d.label) {
66
66
  case 0:
67
- params.page = Number((_a = params.page) !== null && _a !== void 0 ? _a : 0);
67
+ params.page = Number((_a = params.page) !== null && _a !== void 0 ? _a : 1);
68
68
  params.limit = Number((_b = params.limit) !== null && _b !== void 0 ? _b : 50);
69
69
  facet = {};
70
70
  pipelineFacetPaging = [];
@@ -94,11 +94,18 @@ var SearcherV2Flow = /** @class */ (function () {
94
94
  }
95
95
  })];
96
96
  case 1:
97
- result = _c.sent();
97
+ result = _d.sent();
98
98
  ret = {};
99
99
  ret.items = result[0].items;
100
100
  if (params.pageable !== false) {
101
- ret.paging = result[0].paging[0];
101
+ ret.paging = (_c = result[0].paging[0]) !== null && _c !== void 0 ? _c : {
102
+ page: 1,
103
+ limit: 50,
104
+ total: 0,
105
+ totalPages: 0,
106
+ startIndex: 0,
107
+ endIndex: 0
108
+ };
102
109
  }
103
110
  return [2 /*return*/, ret];
104
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.337",
3
+ "version": "2.1.339",
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",
@@ -16,7 +16,7 @@ class SearcherV2Flow {
16
16
  async exec(params: IParams, model: mongoose.Model<any>) {
17
17
 
18
18
 
19
- params.page = Number(params.page ?? 0)
19
+ params.page = Number(params.page ?? 1)
20
20
  params.limit = Number(params.limit ?? 50)
21
21
 
22
22
  const facet: any = {}
@@ -61,7 +61,14 @@ class SearcherV2Flow {
61
61
  ret.items = result[0].items
62
62
 
63
63
  if (params.pageable !== false) {
64
- ret.paging = result[0].paging[0]
64
+ ret.paging = result[0].paging[0] ?? {
65
+ page: 1,
66
+ limit: 50,
67
+ total: 0,
68
+ totalPages: 0,
69
+ startIndex: 0,
70
+ endIndex: 0
71
+ }
65
72
  }
66
73
 
67
74
  return ret