c2-mongoose 2.1.227 → 2.1.229

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.
@@ -25,5 +25,6 @@ declare class SearcherFlow<D> {
25
25
  transformObject(originalObject: any): any;
26
26
  buildDefaultFilters(objectSearch: any): any;
27
27
  isValidObjectId(value: string): boolean;
28
+ buildOrdenation(): any;
28
29
  }
29
30
  export default SearcherFlow;
@@ -100,7 +100,7 @@ var SearcherFlow = /** @class */ (function () {
100
100
  if ((0, Utils_1.isNotEmpty)(this.select)) {
101
101
  stagesItems.push({ $project: BuildSelectSingleFlowItem_1.default.build(model, this.select) });
102
102
  }
103
- // stagesItems.push({ $sort: this.sort })
103
+ stagesItems.push({ $sort: this.buildOrdenation() });
104
104
  if (this.pageable === true) {
105
105
  stagesItems.push({ $skip: ((this.page - 1) * this.limit) || 0 });
106
106
  stagesItems.push({ $limit: this.limit });
@@ -194,6 +194,7 @@ var SearcherFlow = /** @class */ (function () {
194
194
  var condition = {};
195
195
  if ([
196
196
  'filters',
197
+ 'withTotalizers',
197
198
  'onlyMetadata',
198
199
  'projection',
199
200
  'pageable',
@@ -283,6 +284,12 @@ var SearcherFlow = /** @class */ (function () {
283
284
  var objectIdPattern = /^[0-9a-fA-F]{24}$/;
284
285
  return objectIdPattern.test(value);
285
286
  };
287
+ SearcherFlow.prototype.buildOrdenation = function () {
288
+ var order = {};
289
+ this.orderBy = this.orderBy;
290
+ order[this.orderBy] = this.orderSense === "desc" ? -1 : 1;
291
+ return order;
292
+ };
286
293
  return SearcherFlow;
287
294
  }());
288
295
  exports.default = SearcherFlow;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.227",
3
+ "version": "2.1.229",
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",
@@ -66,7 +66,7 @@ class SearcherFlow<D> {
66
66
  stagesItems.push({ $project: BuildSelectSingleFlowItem.build(model, this.select) })
67
67
  }
68
68
 
69
- // stagesItems.push({ $sort: this.sort })
69
+ stagesItems.push({ $sort: this.buildOrdenation() })
70
70
  if (this.pageable === true) {
71
71
  stagesItems.push({ $skip: ((this.page - 1) * this.limit) || 0 })
72
72
  stagesItems.push({ $limit: this.limit })
@@ -167,6 +167,7 @@ class SearcherFlow<D> {
167
167
  let condition = {} as any
168
168
  if ([
169
169
  'filters',
170
+ 'withTotalizers',
170
171
  'onlyMetadata',
171
172
  'projection',
172
173
  'pageable',
@@ -267,6 +268,13 @@ class SearcherFlow<D> {
267
268
  const objectIdPattern = /^[0-9a-fA-F]{24}$/;
268
269
  return objectIdPattern.test(value);
269
270
  }
271
+
272
+ public buildOrdenation() {
273
+ let order = {} as any
274
+ this.orderBy = this.orderBy
275
+ order[this.orderBy] = this.orderSense === "desc" ? -1 : 1
276
+ return order
277
+ }
270
278
  }
271
279
 
272
280
  export default SearcherFlow