c2-mongoose 2.1.66 → 2.1.67

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.
@@ -135,11 +135,20 @@ var SearchFlow = /** @class */ (function () {
135
135
  };
136
136
  SearchFlow.prototype.buildPopulateArray = function () {
137
137
  var populates = [];
138
- for (var _i = 0, _a = this.populate; _i < _a.length; _i++) {
139
- var property = _a[_i];
138
+ var _loop_1 = function () {
140
139
  var _b = property.split('.'), first = _b[0], rest = _b.slice(1);
141
140
  var nested = rest.join('.');
142
- populates.push(this.buildPath(first, nested));
141
+ var populate = this_1.buildPath(first, nested);
142
+ if (Array.isArray(this_1.select)) {
143
+ var selects = this_1.select.filter(function (sel) { return sel.startsWith("".concat(first, ".")); });
144
+ populate.select = selects.join(" ");
145
+ }
146
+ populates.push(populate);
147
+ };
148
+ var this_1 = this;
149
+ for (var _i = 0, _a = this.populate; _i < _a.length; _i++) {
150
+ var property = _a[_i];
151
+ _loop_1();
143
152
  }
144
153
  this.populate = populates;
145
154
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.66",
3
+ "version": "2.1.67",
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",
@@ -69,7 +69,12 @@ abstract class SearchFlow {
69
69
  for (var property of this.populate) {
70
70
  let [first, ...rest] = property.split('.')
71
71
  let nested = rest.join('.')
72
- populates.push(this.buildPath(first, nested))
72
+ let populate = this.buildPath(first, nested)
73
+ if (Array.isArray(this.select)) {
74
+ let selects = (this.select as []).filter((sel: string) => sel.startsWith(`${first}.`))
75
+ populate.select = selects.join(" ")
76
+ }
77
+ populates.push(populate)
73
78
  }
74
79
 
75
80
  this.populate = populates