c2-mongoose 2.1.105 → 2.1.106

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.
@@ -23,11 +23,7 @@ declare abstract class SearchFlow {
23
23
  buildPath(target: string, nested?: string): any;
24
24
  buildOrdenation(): any;
25
25
  buildRegex(searchText: string): RegExp;
26
- searchPageable(model: mongoose.Model<any>, options: SearchOptions): Promise<{
27
- items: any;
28
- paging: any;
29
- metadata: any;
30
- }>;
26
+ searchPageable(model: mongoose.Model<any>, options: SearchOptions): Promise<any>;
31
27
  search(model: mongoose.Model<any>, options?: SearchOptions): Promise<SearchResponse<any>>;
32
28
  /**
33
29
  *
@@ -185,11 +185,11 @@ var SearchFlow = /** @class */ (function () {
185
185
  return new RegExp("".concat(regexExpression), 'i');
186
186
  };
187
187
  SearchFlow.prototype.searchPageable = function (model, options) {
188
- var _a, _b;
188
+ var _a;
189
189
  return __awaiter(this, void 0, void 0, function () {
190
- var stagesItems, stagesPaging, stagesMetadata, facet, _i, stagesMetadata_1, metadata, result, items, _c, _d, populate;
191
- return __generator(this, function (_e) {
192
- switch (_e.label) {
190
+ var stagesItems, stagesPaging, stagesMetadata, facet, _i, stagesMetadata_1, metadata, result, items, _b, _c, populate;
191
+ return __generator(this, function (_d) {
192
+ switch (_d.label) {
193
193
  case 0:
194
194
  stagesItems = [{ $match: this.filters }];
195
195
  if ((0, Utils_1.isNotEmpty)(options.unions)) {
@@ -233,26 +233,22 @@ var SearchFlow = /** @class */ (function () {
233
233
  },
234
234
  ]).session(options === null || options === void 0 ? void 0 : options.session)];
235
235
  case 1:
236
- result = _e.sent();
236
+ result = _d.sent();
237
237
  items = result[0].items;
238
238
  if (!((0, Utils_1.isNotEmpty)(this.populate) && Array.isArray(this.populate))) return [3 /*break*/, 5];
239
- _c = 0, _d = this.populate;
240
- _e.label = 2;
239
+ _b = 0, _c = this.populate;
240
+ _d.label = 2;
241
241
  case 2:
242
- if (!(_c < _d.length)) return [3 /*break*/, 5];
243
- populate = _d[_c];
242
+ if (!(_b < _c.length)) return [3 /*break*/, 5];
243
+ populate = _c[_b];
244
244
  return [4 /*yield*/, model.populate(result[0].items, populate)];
245
245
  case 3:
246
- items = _e.sent();
247
- _e.label = 4;
246
+ items = _d.sent();
247
+ _d.label = 4;
248
248
  case 4:
249
- _c++;
249
+ _b++;
250
250
  return [3 /*break*/, 2];
251
- case 5: return [2 /*return*/, {
252
- items: items,
253
- paging: ((_a = result[0]) === null || _a === void 0 ? void 0 : _a.paging[0]) || { total: 0, page: 1, limit: this.limit },
254
- metadata: ((_b = result[0]) === null || _b === void 0 ? void 0 : _b.metadata[0]) || undefined
255
- }];
251
+ case 5: return [2 /*return*/, __assign(__assign({}, result[0]), { items: items, paging: ((_a = result[0]) === null || _a === void 0 ? void 0 : _a.paging[0]) || { total: 0, page: 1, limit: this.limit } })];
256
252
  }
257
253
  });
258
254
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.105",
3
+ "version": "2.1.106",
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",
@@ -189,9 +189,9 @@ abstract class SearchFlow {
189
189
  }
190
190
 
191
191
  return {
192
+ ...result[0],
192
193
  items,
193
194
  paging: result[0]?.paging[0] || { total: 0, page: 1, limit: this.limit },
194
- metadata: result[0]?.metadata[0] || undefined
195
195
  }
196
196
  }
197
197