c2-mongoose 2.1.334 → 2.1.336

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,11 +58,14 @@ var SearcherV2Flow = /** @class */ (function () {
58
58
  function SearcherV2Flow() {
59
59
  }
60
60
  SearcherV2Flow.prototype.exec = function (params, model) {
61
+ var _a, _b;
61
62
  return __awaiter(this, void 0, void 0, function () {
62
63
  var facet, pipelineFacetPaging, pipelineFacetItems, result, ret;
63
- return __generator(this, function (_a) {
64
- switch (_a.label) {
64
+ return __generator(this, function (_c) {
65
+ switch (_c.label) {
65
66
  case 0:
67
+ params.page = Number((_a = params.page) !== null && _a !== void 0 ? _a : 0);
68
+ params.limit = Number((_b = params.limit) !== null && _b !== void 0 ? _b : 50);
66
69
  facet = {};
67
70
  pipelineFacetPaging = [];
68
71
  pipelineFacetItems = [];
@@ -73,7 +76,7 @@ var SearcherV2Flow = /** @class */ (function () {
73
76
  pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), ProjectFlowItem_1.default.exec(params.select), true);
74
77
  if (params.pageable !== false) {
75
78
  pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), [
76
- { $skip: ((params.page - 1) * params.limit) },
79
+ { $skip: (params.page - 1) * (params.limit) },
77
80
  { $limit: params.limit }
78
81
  ], false);
79
82
  pipelineFacetPaging = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], GroupFlowItem_1.default.exec(params.groupBy, params.sumFields, params.groupDetailed, model), true), PopulateFlowItem_1.default.exec(params.populate, model), true), MatchFlowItem_1.default.exec(params, model), true), BuildPaginationDataFlowItem_1.default.exec(params.page, params.limit), true);
@@ -84,9 +87,14 @@ var SearcherV2Flow = /** @class */ (function () {
84
87
  {
85
88
  $facet: facet
86
89
  }
87
- ], false))];
90
+ ], false), {
91
+ collation: {
92
+ locale: "pt",
93
+ numericOrdering: true
94
+ }
95
+ })];
88
96
  case 1:
89
- result = _a.sent();
97
+ result = _c.sent();
90
98
  ret = {};
91
99
  ret.items = result[0].items;
92
100
  if (params.pageable !== false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.334",
3
+ "version": "2.1.336",
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",
@@ -14,6 +14,11 @@ export interface IParams {
14
14
  class SearcherV2Flow {
15
15
 
16
16
  async exec(params: IParams, model: mongoose.Model<any>) {
17
+
18
+
19
+ params.page = Number(params.page ?? 0)
20
+ params.limit = Number(params.limit ?? 50)
21
+
17
22
  const facet: any = {}
18
23
  let pipelineFacetPaging: any[] = []
19
24
  let pipelineFacetItems: any[] = []
@@ -26,15 +31,15 @@ class SearcherV2Flow {
26
31
  if (params.pageable !== false) {
27
32
  pipelineFacetItems = [
28
33
  ...pipelineFacetItems,
29
- { $skip: (((params.page - 1) as number) * (params.limit as number)) },
30
- { $limit: params.limit as number }
34
+ { $skip: (params.page - 1) * (params.limit) },
35
+ { $limit: params.limit }
31
36
  ]
32
37
 
33
38
  pipelineFacetPaging = [
34
39
  ...GroupFlowItem.exec(params.groupBy, params.sumFields, params.groupDetailed, model),
35
40
  ...PopulateFlowItem.exec(params.populate, model),
36
41
  ...MatchFlowItem.exec(params, model),
37
- ...BuildPaginationDataFlowItem.exec(params.page as number, params.limit as number),
42
+ ...BuildPaginationDataFlowItem.exec(params.page, params.limit),
38
43
  ]
39
44
  facet.paging = pipelineFacetPaging
40
45
  }
@@ -45,7 +50,12 @@ class SearcherV2Flow {
45
50
  {
46
51
  $facet: facet
47
52
  }
48
- ])
53
+ ], {
54
+ collation: {
55
+ locale: "pt",
56
+ numericOrdering: true
57
+ }
58
+ })
49
59
 
50
60
  const ret: any = {}
51
61
  ret.items = result[0].items