c2-mongoose 2.1.62 → 2.1.63

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.
@@ -18,7 +18,7 @@ declare abstract class SearchFlow {
18
18
  buildPopulate(): any;
19
19
  buildProjections(): {
20
20
  [key: string]: number;
21
- };
21
+ } | undefined;
22
22
  buildPath(target: string, nested?: string): any;
23
23
  buildOrdenation(): any;
24
24
  buildRegex(searchText: string): RegExp;
@@ -121,7 +121,7 @@ var SearchFlow = /** @class */ (function () {
121
121
  };
122
122
  SearchFlow.prototype.buildProjections = function () {
123
123
  if (!Array.isArray(this.select)) {
124
- return {};
124
+ return undefined;
125
125
  }
126
126
  var projection = {};
127
127
  for (var _i = 0, _a = this.select; _i < _a.length; _i++) {
@@ -168,7 +168,8 @@ var SearchFlow = /** @class */ (function () {
168
168
  { $match: this.filters },
169
169
  { $sort: this.sort },
170
170
  { $skip: (this.page - 1) * this.limit },
171
- { $limit: this.limit }
171
+ { $limit: this.limit },
172
+ this.projection ? { $project: this.projection } : { $addFields: {} }
172
173
  ], options.pipelines, true);
173
174
  return [4 /*yield*/, model.aggregate([
174
175
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.62",
3
+ "version": "2.1.63",
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",
@@ -49,7 +49,7 @@ abstract class SearchFlow {
49
49
 
50
50
  buildProjections() {
51
51
  if (!Array.isArray(this.select)) {
52
- return {}
52
+ return undefined
53
53
  }
54
54
 
55
55
  let projection: { [key: string]: number } = {}
@@ -95,7 +95,7 @@ abstract class SearchFlow {
95
95
  { $sort: this.sort },
96
96
  { $skip: (this.page - 1) * this.limit },
97
97
  { $limit: this.limit },
98
- // { $project: this.projection },
98
+ this.projection ? { $project: this.projection } : { $addFields: {} },
99
99
  ...options.pipelines
100
100
  ]
101
101