c2-mongoose 2.1.140 → 2.1.142

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.
@@ -75,13 +75,8 @@ var SearchFlow = /** @class */ (function () {
75
75
  for (var _i = 0, _a = this.select; _i < _a.length; _i++) {
76
76
  var field = _a[_i];
77
77
  var include = field.startsWith("-") ? false : true;
78
- projection = __assign(__assign({}, projection), this.buildProjectionNested({}, field, include));
79
- // if (field.startsWith("-")) {
80
- // field = field.substring(1)
81
- // projection[field] = 0;
82
- // } else {
83
- // projection[field] = 1;
84
- // }
78
+ field = field.replace("-", "");
79
+ projection = __assign(__assign({}, projection), this.buildProjectionNested(projection, field, include));
85
80
  }
86
81
  return projection;
87
82
  };
@@ -92,7 +87,7 @@ var SearchFlow = /** @class */ (function () {
92
87
  projectCurrent[first] = include ? 1 : 0;
93
88
  return projectCurrent;
94
89
  }
95
- projectCurrent[first] = this.buildProjectionNested({}, rest.join("."), include);
90
+ projectCurrent[first] = __assign(__assign({}, projectCurrent[first]), this.buildProjectionNested({}, rest.join("."), include));
96
91
  return projectCurrent;
97
92
  };
98
93
  SearchFlow.prototype.buildPopulate = function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.140",
3
+ "version": "2.1.142",
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",
@@ -38,16 +38,11 @@ abstract class SearchFlow {
38
38
  let projection: any = {}
39
39
  for (var field of this.select) {
40
40
  let include = field.startsWith("-") ? false : true
41
+ field = field.replace("-", "")
41
42
  projection = {
42
43
  ...projection,
43
- ...this.buildProjectionNested({}, field, include)
44
+ ...this.buildProjectionNested(projection, field, include)
44
45
  }
45
- // if (field.startsWith("-")) {
46
- // field = field.substring(1)
47
- // projection[field] = 0;
48
- // } else {
49
- // projection[field] = 1;
50
- // }
51
46
 
52
47
  }
53
48
  return projection;
@@ -62,8 +57,10 @@ abstract class SearchFlow {
62
57
  return projectCurrent
63
58
  }
64
59
 
65
- projectCurrent[first] = this.buildProjectionNested({}, rest.join("."), include)
66
-
60
+ projectCurrent[first] = {
61
+ ...projectCurrent[first],
62
+ ...this.buildProjectionNested({}, rest.join("."), include)
63
+ }
67
64
  return projectCurrent
68
65
  }
69
66