c2-mongoose 2.1.53 → 2.1.54

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.
@@ -71,7 +71,7 @@ var SearchFlow = /** @class */ (function () {
71
71
  * @deprecated
72
72
  * @returns
73
73
  */
74
- this.searchPageableOld = function (model) { return __awaiter(_this, void 0, void 0, function () {
74
+ this.searchPageableOld = function (model, session) { return __awaiter(_this, void 0, void 0, function () {
75
75
  var sort, items;
76
76
  return __generator(this, function (_a) {
77
77
  switch (_a.label) {
@@ -83,6 +83,7 @@ var SearchFlow = /** @class */ (function () {
83
83
  .skip((this.page - 1) * this.limit)
84
84
  .limit(this.limit)
85
85
  .sort(sort)
86
+ .session(session)
86
87
  .collation({
87
88
  locale: Environment_1.dbCollation || "pt"
88
89
  })];
@@ -193,15 +194,15 @@ var SearchFlow = /** @class */ (function () {
193
194
  if (!(options === null || options === void 0 ? void 0 : options.pipelines)) return [3 /*break*/, 2];
194
195
  return [4 /*yield*/, this.searchPageable(model, options)];
195
196
  case 1: return [2 /*return*/, _a.sent()];
196
- case 2: return [4 /*yield*/, this.searchPageableOld(model)];
197
+ case 2: return [4 /*yield*/, this.searchPageableOld(model, options === null || options === void 0 ? void 0 : options.session)];
197
198
  case 3: return [2 /*return*/, _a.sent()];
198
- case 4: return [4 /*yield*/, this.searchNoPageable(model)];
199
+ case 4: return [4 /*yield*/, this.searchNoPageable(model, options === null || options === void 0 ? void 0 : options.session)];
199
200
  case 5: return [2 /*return*/, _a.sent()];
200
201
  }
201
202
  });
202
203
  });
203
204
  };
204
- SearchFlow.prototype.searchNoPageable = function (model) {
205
+ SearchFlow.prototype.searchNoPageable = function (model, session) {
205
206
  return __awaiter(this, void 0, void 0, function () {
206
207
  var sort, items;
207
208
  return __generator(this, function (_a) {
@@ -212,6 +213,7 @@ var SearchFlow = /** @class */ (function () {
212
213
  .find(this.filters, this.select)
213
214
  .populate(this.populate)
214
215
  .sort(sort)
216
+ .session(session)
215
217
  .collation({
216
218
  locale: Environment_1.dbCollation || "pt"
217
219
  })];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.53",
3
+ "version": "2.1.54",
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",
@@ -114,10 +114,10 @@ abstract class SearchFlow {
114
114
  if (options?.pipelines) {
115
115
  return await this.searchPageable(model, options)
116
116
  }
117
- return await this.searchPageableOld(model)
117
+ return await this.searchPageableOld(model, options?.session)
118
118
  }
119
119
 
120
- return await this.searchNoPageable(model)
120
+ return await this.searchNoPageable(model, options?.session)
121
121
  }
122
122
 
123
123
  /**
@@ -126,7 +126,7 @@ abstract class SearchFlow {
126
126
  * @deprecated
127
127
  * @returns
128
128
  */
129
- private searchPageableOld = async (model: mongoose.Model<any>): Promise<SearchResponse<any>> => {
129
+ private searchPageableOld = async (model: mongoose.Model<any>, session?: ClientSession): Promise<SearchResponse<any>> => {
130
130
  const sort = this.buildOrdenation()
131
131
  var items = await model
132
132
  .find(this.filters, this.select)
@@ -134,6 +134,7 @@ abstract class SearchFlow {
134
134
  .skip((this.page - 1) * this.limit)
135
135
  .limit(this.limit)
136
136
  .sort(sort)
137
+ .session(session!)
137
138
  .collation({
138
139
  locale: dbCollation || "pt"
139
140
  }) as []
@@ -141,12 +142,13 @@ abstract class SearchFlow {
141
142
  return this.result(model, items)
142
143
  }
143
144
 
144
- private async searchNoPageable(model: mongoose.Model<any>): Promise<SearchResponse<any>> {
145
+ private async searchNoPageable(model: mongoose.Model<any>, session?: ClientSession): Promise<SearchResponse<any>> {
145
146
  const sort = this.buildOrdenation()
146
147
  var items = await model
147
148
  .find(this.filters, this.select)
148
149
  .populate(this.populate)
149
150
  .sort(sort)
151
+ .session(session!)
150
152
  .collation({
151
153
  locale: dbCollation || "pt"
152
154
  }) as []