c2-mongoose 2.1.259 → 2.1.261

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.
@@ -165,10 +165,11 @@ var SearchFlow = /** @class */ (function () {
165
165
  return new RegExp("".concat(regexExpression), 'i');
166
166
  };
167
167
  SearchFlow.prototype.searchNoPageable = function (model, options) {
168
+ var _a;
168
169
  return __awaiter(this, void 0, void 0, function () {
169
- var stagesItems, stagesMetadata, facet, _i, stagesMetadata_1, metadata, result, _a, _b, populate, _c, resultAux;
170
- return __generator(this, function (_d) {
171
- switch (_d.label) {
170
+ var stagesItems, stagesMetadata, facet, _i, stagesMetadata_1, metadata, result, _b, _c, populate, _d, resultAux;
171
+ return __generator(this, function (_e) {
172
+ switch (_e.label) {
172
173
  case 0:
173
174
  stagesItems = [];
174
175
  if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
@@ -199,26 +200,26 @@ var SearchFlow = /** @class */ (function () {
199
200
  $facet: facet
200
201
  },
201
202
  ], {
202
- collation: {
203
+ collation: (_a = options === null || options === void 0 ? void 0 : options.collaction) !== null && _a !== void 0 ? _a : {
203
204
  locale: "pt",
204
205
  numericOrdering: true
205
206
  }
206
207
  }).session(options === null || options === void 0 ? void 0 : options.session)];
207
208
  case 1:
208
- result = _d.sent();
209
+ result = _e.sent();
209
210
  if (!((0, Utils_1.isNotEmpty)(this.populate) && Array.isArray(this.populate))) return [3 /*break*/, 5];
210
- _a = 0, _b = this.populate;
211
- _d.label = 2;
211
+ _b = 0, _c = this.populate;
212
+ _e.label = 2;
212
213
  case 2:
213
- if (!(_a < _b.length)) return [3 /*break*/, 5];
214
- populate = _b[_a];
215
- _c = result[0];
214
+ if (!(_b < _c.length)) return [3 /*break*/, 5];
215
+ populate = _c[_b];
216
+ _d = result[0];
216
217
  return [4 /*yield*/, model.populate(result[0].items, populate)];
217
218
  case 3:
218
- _c.items = _d.sent();
219
- _d.label = 4;
219
+ _d.items = _e.sent();
220
+ _e.label = 4;
220
221
  case 4:
221
- _a++;
222
+ _b++;
222
223
  return [3 /*break*/, 2];
223
224
  case 5:
224
225
  resultAux = this.transformObject(result[0]);
@@ -228,10 +229,11 @@ var SearchFlow = /** @class */ (function () {
228
229
  });
229
230
  };
230
231
  SearchFlow.prototype.searchPageable = function (model, options) {
232
+ var _a;
231
233
  return __awaiter(this, void 0, void 0, function () {
232
- var stagesItems, stagesPaging, stagesMetadata, facet, _i, stagesMetadata_2, metadata, result, _a, _b, populate, _c, resultAux;
233
- return __generator(this, function (_d) {
234
- switch (_d.label) {
234
+ var stagesItems, stagesPaging, stagesMetadata, facet, _i, stagesMetadata_2, metadata, result, _b, _c, populate, _d, resultAux;
235
+ return __generator(this, function (_e) {
236
+ switch (_e.label) {
235
237
  case 0:
236
238
  stagesItems = [];
237
239
  if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
@@ -280,10 +282,6 @@ var SearchFlow = /** @class */ (function () {
280
282
  facet.items = stagesItems;
281
283
  facet.paging = stagesPaging;
282
284
  }
283
- // const facet: { [key: string]: any } = {
284
- // items: stagesItems,
285
- // paging: stagesPaging,
286
- // }
287
285
  for (_i = 0, stagesMetadata_2 = stagesMetadata; _i < stagesMetadata_2.length; _i++) {
288
286
  metadata = stagesMetadata_2[_i];
289
287
  facet[metadata.id] = metadata.conditions;
@@ -293,26 +291,26 @@ var SearchFlow = /** @class */ (function () {
293
291
  $facet: facet
294
292
  },
295
293
  ], {
296
- collation: {
294
+ collation: (_a = options === null || options === void 0 ? void 0 : options.collaction) !== null && _a !== void 0 ? _a : {
297
295
  locale: "pt",
298
296
  numericOrdering: true
299
297
  }
300
298
  }).session(options === null || options === void 0 ? void 0 : options.session)];
301
299
  case 1:
302
- result = _d.sent();
300
+ result = _e.sent();
303
301
  if (!((0, Utils_1.isNotEmpty)(this.populate) && Array.isArray(this.populate))) return [3 /*break*/, 5];
304
- _a = 0, _b = this.populate;
305
- _d.label = 2;
302
+ _b = 0, _c = this.populate;
303
+ _e.label = 2;
306
304
  case 2:
307
- if (!(_a < _b.length)) return [3 /*break*/, 5];
308
- populate = _b[_a];
309
- _c = result[0];
305
+ if (!(_b < _c.length)) return [3 /*break*/, 5];
306
+ populate = _c[_b];
307
+ _d = result[0];
310
308
  return [4 /*yield*/, model.populate(result[0].items, populate)];
311
309
  case 3:
312
- _c.items = _d.sent();
313
- _d.label = 4;
310
+ _d.items = _e.sent();
311
+ _e.label = 4;
314
312
  case 4:
315
- _a++;
313
+ _b++;
316
314
  return [3 /*break*/, 2];
317
315
  case 5:
318
316
  resultAux = this.transformObject(result[0]);
@@ -86,10 +86,11 @@ var SearcherFlow = /** @class */ (function () {
86
86
  this.limit = Number(this.limit);
87
87
  };
88
88
  SearcherFlow.prototype.search = function (options) {
89
+ var _a;
89
90
  return __awaiter(this, void 0, void 0, function () {
90
- var stagesItems, stagesPaging, stagesMetadata, facet, _i, stagesMetadata_1, metadata, result, _a, resultAux;
91
- return __generator(this, function (_b) {
92
- switch (_b.label) {
91
+ var stagesItems, stagesPaging, stagesMetadata, facet, _i, stagesMetadata_1, metadata, result, _b, resultAux;
92
+ return __generator(this, function (_c) {
93
+ switch (_c.label) {
93
94
  case 0:
94
95
  stagesItems = [];
95
96
  if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
@@ -156,19 +157,19 @@ var SearcherFlow = /** @class */ (function () {
156
157
  $facet: facet
157
158
  },
158
159
  ], {
159
- collation: {
160
+ collation: (_a = options === null || options === void 0 ? void 0 : options.collaction) !== null && _a !== void 0 ? _a : {
160
161
  locale: "pt",
161
162
  numericOrdering: true
162
163
  }
163
164
  }).session(options === null || options === void 0 ? void 0 : options.session)];
164
165
  case 1:
165
- result = _b.sent();
166
+ result = _c.sent();
166
167
  if (!(0, Utils_1.isNotEmpty)(this.populate)) return [3 /*break*/, 3];
167
- _a = result[0];
168
+ _b = result[0];
168
169
  return [4 /*yield*/, this.model.populate(result[0].items, BuildPopulateSingleFlowItem_1.default.buildPopulate(this.model, this.populate, this.select))];
169
170
  case 2:
170
- _a.items = _b.sent();
171
- _b.label = 3;
171
+ _b.items = _c.sent();
172
+ _c.label = 3;
172
173
  case 3:
173
174
  resultAux = this.transformObject(result[0]);
174
175
  return [2 /*return*/, resultAux];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.259",
3
+ "version": "2.1.261",
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",
@@ -194,7 +194,7 @@ abstract class SearchFlow {
194
194
  $facet: facet
195
195
  },
196
196
  ], {
197
- collation: {
197
+ collation: options?.collaction ?? {
198
198
  locale: "pt",
199
199
  numericOrdering: true
200
200
  }
@@ -270,10 +270,6 @@ abstract class SearchFlow {
270
270
  facet.items = stagesItems
271
271
  facet.paging = stagesPaging
272
272
  }
273
- // const facet: { [key: string]: any } = {
274
- // items: stagesItems,
275
- // paging: stagesPaging,
276
- // }
277
273
 
278
274
  for (let metadata of stagesMetadata) {
279
275
  facet[metadata.id] = metadata.conditions
@@ -285,7 +281,7 @@ abstract class SearchFlow {
285
281
  $facet: facet
286
282
  },
287
283
  ], {
288
- collation: {
284
+ collation: options?.collaction ?? {
289
285
  locale: "pt",
290
286
  numericOrdering: true
291
287
  }
@@ -119,7 +119,7 @@ class SearcherFlow<D> {
119
119
  $facet: facet
120
120
  },
121
121
  ], {
122
- collation: {
122
+ collation: options?.collaction ?? {
123
123
  locale: "pt",
124
124
  numericOrdering: true
125
125
  }
@@ -1,4 +1,5 @@
1
1
  import { ClientSession } from "mongoose";
2
+ import { CollationOptions } from "mongodb";
2
3
 
3
4
  declare interface SearchResponse<T> {
4
5
  [key: string]: any;
@@ -21,7 +22,8 @@ declare interface SearchOptions {
21
22
  pipelines: PipelineStage[],
22
23
  paging: PipelineStage[],
23
24
  metadata: PipelineStage[],
24
- session?: ClientSession
25
+ session?: ClientSession,
26
+ collaction?: CollationOptions
25
27
  }
26
28
 
27
29
  export { SearchResponse, Pagination, PipelineStage, SearchOptions };