c2-mongoose 2.1.145 → 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,23 +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
- populate.select = selects.map(function (sel) { return sel.split(".")[1]; }).join(" ");
110
- }
111
- populates.push(populate);
112
- };
113
- var this_1 = this;
114
100
  for (var _i = 0, _a = this.populate; _i < _a.length; _i++) {
115
101
  var property = _a[_i];
116
- _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)
117
117
  }
118
118
  return populates;
119
119
  };
@@ -154,9 +154,9 @@ var SearchFlow = /** @class */ (function () {
154
154
  SearchFlow.prototype.searchNoPageable = function (model, options) {
155
155
  var _a;
156
156
  return __awaiter(this, void 0, void 0, function () {
157
- var stagesItems, stagesMetadata, facet, _i, stagesMetadata_1, metadata, result, items, _b, _c, populate, resultAux;
158
- return __generator(this, function (_d) {
159
- 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) {
160
160
  case 0:
161
161
  stagesItems = [];
162
162
  if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
@@ -188,18 +188,18 @@ var SearchFlow = /** @class */ (function () {
188
188
  },
189
189
  ]).session(options === null || options === void 0 ? void 0 : options.session)];
190
190
  case 1:
191
- result = _d.sent();
192
- items = result[0].items;
191
+ result = _e.sent();
193
192
  if (!((0, Utils_1.isNotEmpty)(this.populate) && Array.isArray(this.populate))) return [3 /*break*/, 5];
194
193
  _b = 0, _c = this.populate;
195
- _d.label = 2;
194
+ _e.label = 2;
196
195
  case 2:
197
196
  if (!(_b < _c.length)) return [3 /*break*/, 5];
198
197
  populate = _c[_b];
198
+ _d = result[0];
199
199
  return [4 /*yield*/, model.populate(result[0].items, populate)];
200
200
  case 3:
201
- items = _d.sent();
202
- _d.label = 4;
201
+ _d.items = _e.sent();
202
+ _e.label = 4;
203
203
  case 4:
204
204
  _b++;
205
205
  return [3 /*break*/, 2];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.145",
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,14 +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
- populate.select = selects.map((sel: string) => sel.split(".")[1]).join(" ")
86
- }
87
- 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)
88
92
  }
89
93
 
90
94
  return populates
@@ -169,11 +173,9 @@ abstract class SearchFlow {
169
173
  ]
170
174
  ).session(options?.session as ClientSession)
171
175
 
172
- var items = result[0].items
173
-
174
176
  if (isNotEmpty(this.populate) && Array.isArray(this.populate)) {
175
177
  for (var populate of this.populate) {
176
- items = await model.populate(result[0].items, populate)
178
+ result[0].items = await model.populate(result[0].items, populate)
177
179
  }
178
180
  }
179
181