c2-mongoose 2.1.74 → 2.1.75

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.
@@ -15,7 +15,9 @@ declare abstract class SearchFlow {
15
15
  [key: string]: number;
16
16
  } | undefined;
17
17
  constructor(params: any);
18
- buildProjections(): any;
18
+ buildProjections(): {
19
+ [key: string]: number;
20
+ } | undefined;
19
21
  buildPopulate(): any;
20
22
  buildPopulateArray(): void;
21
23
  buildPath(target: string, nested?: string): any;
@@ -109,14 +109,18 @@ var SearchFlow = /** @class */ (function () {
109
109
  if (!Array.isArray(this.select)) {
110
110
  return undefined;
111
111
  }
112
- var projection = undefined;
112
+ var projection = {};
113
+ var found = false;
113
114
  for (var _i = 0, _a = this.select; _i < _a.length; _i++) {
114
115
  var field = _a[_i];
115
- if (!field.indexOf(".")) {
116
+ if (field.indexOf(".") < 0) {
116
117
  projection[field] = 1;
118
+ found = true;
117
119
  }
118
120
  }
119
- return projection;
121
+ if (found)
122
+ return projection;
123
+ return undefined;
120
124
  };
121
125
  SearchFlow.prototype.buildPopulate = function () {
122
126
  if ((0, Utils_1.isEmpty)(this.populate)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.74",
3
+ "version": "2.1.75",
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",
@@ -36,14 +36,18 @@ abstract class SearchFlow {
36
36
  return undefined
37
37
  }
38
38
 
39
- let projection: any = undefined
39
+ let projection: { [key: string]: number } = {}
40
+ let found = false
40
41
  for (var field of this.select) {
41
- if (!field.indexOf(".")) {
42
+ if (field.indexOf(".") < 0) {
42
43
  projection[field] = 1
44
+ found = true
43
45
  }
44
46
  }
45
47
 
46
- return projection
48
+ if (found)
49
+ return projection;
50
+ return undefined
47
51
  }
48
52
 
49
53
  public buildPopulate(): any {