c2-mongoose 2.1.146 → 2.1.147

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.
@@ -97,26 +97,23 @@ var SearchFlow = /** @class */ (function () {
97
97
  return;
98
98
  }
99
99
  var populates = [];
100
- var _loop_1 = function () {
101
- if (property.includes(".")) {
102
- return "continue";
103
- }
104
- var _b = property.split('.'), first = _b[0], rest = _b.slice(1);
105
- var nested = rest.join('.');
106
- var populate = this_1.buildPath(first, nested);
107
- if (Array.isArray(this_1.select)) {
108
- var selects = this_1.select.filter(function (sel) { return sel.startsWith("".concat(first, ".")); });
109
- var select = selects.map(function (sel) { return sel.split(".")[1]; }).join(" ");
110
- if ((0, Utils_1.isNotEmpty)(select)) {
111
- populate.select = select;
112
- }
113
- }
114
- populates.push(populate);
115
- };
116
- var this_1 = this;
117
100
  for (var _i = 0, _a = this.populate; _i < _a.length; _i++) {
118
101
  var property = _a[_i];
119
- _loop_1();
102
+ if (property.includes(".")) {
103
+ continue;
104
+ }
105
+ populates.push(property);
106
+ // let [first, ...rest] = property.split('.')
107
+ // let nested = rest.join('.')
108
+ // let populate = this.buildPath(first, nested)
109
+ // if (Array.isArray(this.select)) {
110
+ // let selects = (this.select as []).filter((sel: string) => sel.startsWith(`${first}.`))
111
+ // let select = selects.map((sel: string) => sel.split(".")[1]).join(" ")
112
+ // if (isNotEmpty(select)) {
113
+ // populate.select = select
114
+ // }
115
+ // }
116
+ // populates.push(populate)
120
117
  }
121
118
  return populates;
122
119
  };
@@ -157,9 +154,9 @@ var SearchFlow = /** @class */ (function () {
157
154
  SearchFlow.prototype.searchNoPageable = function (model, options) {
158
155
  var _a;
159
156
  return __awaiter(this, void 0, void 0, function () {
160
- var stagesItems, stagesMetadata, facet, _i, stagesMetadata_1, metadata, result, items, _b, _c, populate, resultAux;
161
- return __generator(this, function (_d) {
162
- switch (_d.label) {
157
+ var stagesItems, stagesMetadata, facet, _i, stagesMetadata_1, metadata, result, _b, _c, populate, _d, resultAux;
158
+ return __generator(this, function (_e) {
159
+ switch (_e.label) {
163
160
  case 0:
164
161
  stagesItems = [];
165
162
  if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
@@ -191,18 +188,18 @@ var SearchFlow = /** @class */ (function () {
191
188
  },
192
189
  ]).session(options === null || options === void 0 ? void 0 : options.session)];
193
190
  case 1:
194
- result = _d.sent();
195
- items = result[0].items;
191
+ result = _e.sent();
196
192
  if (!((0, Utils_1.isNotEmpty)(this.populate) && Array.isArray(this.populate))) return [3 /*break*/, 5];
197
193
  _b = 0, _c = this.populate;
198
- _d.label = 2;
194
+ _e.label = 2;
199
195
  case 2:
200
196
  if (!(_b < _c.length)) return [3 /*break*/, 5];
201
197
  populate = _c[_b];
198
+ _d = result[0];
202
199
  return [4 /*yield*/, model.populate(result[0].items, populate)];
203
200
  case 3:
204
- items = _d.sent();
205
- _d.label = 4;
201
+ _d.items = _e.sent();
202
+ _e.label = 4;
206
203
  case 4:
207
204
  _b++;
208
205
  return [3 /*break*/, 2];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.146",
3
+ "version": "2.1.147",
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",
@@ -77,17 +77,18 @@ abstract class SearchFlow {
77
77
  if (property.includes(".")) {
78
78
  continue
79
79
  }
80
- let [first, ...rest] = property.split('.')
81
- let nested = rest.join('.')
82
- let populate = this.buildPath(first, nested)
83
- if (Array.isArray(this.select)) {
84
- let selects = (this.select as []).filter((sel: string) => sel.startsWith(`${first}.`))
85
- let select = selects.map((sel: string) => sel.split(".")[1]).join(" ")
86
- if (isNotEmpty(select)) {
87
- populate.select = select
88
- }
89
- }
90
- populates.push(populate)
80
+ populates.push(property)
81
+ // let [first, ...rest] = property.split('.')
82
+ // let nested = rest.join('.')
83
+ // let populate = this.buildPath(first, nested)
84
+ // if (Array.isArray(this.select)) {
85
+ // let selects = (this.select as []).filter((sel: string) => sel.startsWith(`${first}.`))
86
+ // let select = selects.map((sel: string) => sel.split(".")[1]).join(" ")
87
+ // if (isNotEmpty(select)) {
88
+ // populate.select = select
89
+ // }
90
+ // }
91
+ // populates.push(populate)
91
92
  }
92
93
 
93
94
  return populates
@@ -172,11 +173,9 @@ abstract class SearchFlow {
172
173
  ]
173
174
  ).session(options?.session as ClientSession)
174
175
 
175
- var items = result[0].items
176
-
177
176
  if (isNotEmpty(this.populate) && Array.isArray(this.populate)) {
178
177
  for (var populate of this.populate) {
179
- items = await model.populate(result[0].items, populate)
178
+ result[0].items = await model.populate(result[0].items, populate)
180
179
  }
181
180
  }
182
181