c2-mongoose 2.1.141 → 2.1.143

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.
@@ -76,13 +76,7 @@ var SearchFlow = /** @class */ (function () {
76
76
  var field = _a[_i];
77
77
  var include = field.startsWith("-") ? false : true;
78
78
  field = field.replace("-", "");
79
- projection = __assign(__assign({}, projection), this.buildProjectionNested({}, field, include));
80
- // if (field.startsWith("-")) {
81
- // field = field.substring(1)
82
- // projection[field] = 0;
83
- // } else {
84
- // projection[field] = 1;
85
- // }
79
+ projection = __assign(__assign({}, projection), this.buildProjectionNested(projection, field, include));
86
80
  }
87
81
  return projection;
88
82
  };
@@ -227,9 +221,9 @@ var SearchFlow = /** @class */ (function () {
227
221
  };
228
222
  SearchFlow.prototype.searchPageable = function (model, options) {
229
223
  return __awaiter(this, void 0, void 0, function () {
230
- var stagesItems, stagesPaging, stagesMetadata, facet, _i, stagesMetadata_2, metadata, result, items, _a, _b, populate, resultAux;
231
- return __generator(this, function (_c) {
232
- switch (_c.label) {
224
+ var stagesItems, stagesPaging, stagesMetadata, facet, _i, stagesMetadata_2, metadata, result, _a, _b, populate, _c, resultAux;
225
+ return __generator(this, function (_d) {
226
+ switch (_d.label) {
233
227
  case 0:
234
228
  stagesItems = [];
235
229
  if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
@@ -271,20 +265,22 @@ var SearchFlow = /** @class */ (function () {
271
265
  {
272
266
  $facet: facet
273
267
  },
274
- ]).session(options === null || options === void 0 ? void 0 : options.session)];
268
+ ]).session(options === null || options === void 0 ? void 0 : options.session)
269
+ // var items = result[0].items
270
+ ];
275
271
  case 1:
276
- result = _c.sent();
277
- items = result[0].items;
272
+ result = _d.sent();
278
273
  if (!((0, Utils_1.isNotEmpty)(this.populate) && Array.isArray(this.populate))) return [3 /*break*/, 5];
279
274
  _a = 0, _b = this.populate;
280
- _c.label = 2;
275
+ _d.label = 2;
281
276
  case 2:
282
277
  if (!(_a < _b.length)) return [3 /*break*/, 5];
283
278
  populate = _b[_a];
279
+ _c = result[0];
284
280
  return [4 /*yield*/, model.populate(result[0].items, populate)];
285
281
  case 3:
286
- items = _c.sent();
287
- _c.label = 4;
282
+ _c.items = _d.sent();
283
+ _d.label = 4;
288
284
  case 4:
289
285
  _a++;
290
286
  return [3 /*break*/, 2];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.141",
3
+ "version": "2.1.143",
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",
@@ -41,14 +41,8 @@ abstract class SearchFlow {
41
41
  field = field.replace("-", "")
42
42
  projection = {
43
43
  ...projection,
44
- ...this.buildProjectionNested({}, field, include)
44
+ ...this.buildProjectionNested(projection, field, include)
45
45
  }
46
- // if (field.startsWith("-")) {
47
- // field = field.substring(1)
48
- // projection[field] = 0;
49
- // } else {
50
- // projection[field] = 1;
51
- // }
52
46
 
53
47
  }
54
48
  return projection;
@@ -261,11 +255,11 @@ abstract class SearchFlow {
261
255
  ]
262
256
  ).session(options?.session as ClientSession)
263
257
 
264
- var items = result[0].items
258
+ // var items = result[0].items
265
259
 
266
260
  if (isNotEmpty(this.populate) && Array.isArray(this.populate)) {
267
261
  for (var populate of this.populate) {
268
- items = await model.populate(result[0].items, populate)
262
+ result[0].items = await model.populate(result[0].items, populate)
269
263
  }
270
264
  }
271
265