c2-mongoose 2.1.69 → 2.1.72

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.
@@ -112,7 +112,9 @@ var SearchFlow = /** @class */ (function () {
112
112
  var projection = {};
113
113
  for (var _i = 0, _a = this.select; _i < _a.length; _i++) {
114
114
  var field = _a[_i];
115
- projection[field] = 1;
115
+ if (field.indexOf(".")) {
116
+ projection[field] = 1;
117
+ }
116
118
  }
117
119
  return projection;
118
120
  };
@@ -141,7 +143,7 @@ var SearchFlow = /** @class */ (function () {
141
143
  var populate = this_1.buildPath(first, nested);
142
144
  if (Array.isArray(this_1.select)) {
143
145
  var selects = this_1.select.filter(function (sel) { return sel.startsWith("".concat(first, ".")); });
144
- populate.select = selects.map(function (sel) { return sel.split(".")[0]; }).join(" ");
146
+ populate.select = selects.map(function (sel) { return sel.split(".")[1]; }).join(" ");
145
147
  }
146
148
  populates.push(populate);
147
149
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.69",
3
+ "version": "2.1.72",
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,7 +38,9 @@ abstract class SearchFlow {
38
38
 
39
39
  let projection: { [key: string]: number } = {}
40
40
  for (var field of this.select) {
41
- projection[field] = 1
41
+ if (field.indexOf(".")) {
42
+ projection[field] = 1
43
+ }
42
44
  }
43
45
 
44
46
  return projection
@@ -72,7 +74,7 @@ abstract class SearchFlow {
72
74
  let populate = this.buildPath(first, nested)
73
75
  if (Array.isArray(this.select)) {
74
76
  let selects = (this.select as []).filter((sel: string) => sel.startsWith(`${first}.`))
75
- populate.select = selects.map((sel: string) => sel.split(".")[0]).join(" ")
77
+ populate.select = selects.map((sel: string) => sel.split(".")[1]).join(" ")
76
78
  }
77
79
  populates.push(populate)
78
80
  }