c2-mongoose 2.1.19 → 2.1.20

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.
@@ -1,4 +1,4 @@
1
- import mongoose from "mongoose";
1
+ import mongoose, { ClientSession } from "mongoose";
2
2
  import { SearchResponse } from "../types/SearchResponse";
3
3
  declare abstract class SearchFlow {
4
4
  searchText: string;
@@ -21,7 +21,7 @@ declare abstract class SearchFlow {
21
21
  private result;
22
22
  count(model: mongoose.Model<any>): Promise<number>;
23
23
  findOne(repository: mongoose.Model<any>, model: any, params?: any): Promise<any>;
24
- sumBy(model: mongoose.Model<any>, _sum: any, _by: any): Promise<any[]>;
24
+ sumBy(model: mongoose.Model<any>, _sum: any, _by: any, session?: ClientSession): Promise<any[]>;
25
25
  buildDefaultFilters(objectSearch: any): any;
26
26
  addFilterModel(model: any, filters: any): void;
27
27
  }
@@ -215,7 +215,7 @@ var SearchFlow = /** @class */ (function () {
215
215
  });
216
216
  });
217
217
  };
218
- SearchFlow.prototype.sumBy = function (model, _sum, _by) {
218
+ SearchFlow.prototype.sumBy = function (model, _sum, _by, session) {
219
219
  return __awaiter(this, void 0, void 0, function () {
220
220
  var ret;
221
221
  return __generator(this, function (_a) {
@@ -231,7 +231,7 @@ var SearchFlow = /** @class */ (function () {
231
231
  count: { "$sum": 1 }
232
232
  }
233
233
  }
234
- ])];
234
+ ]).session(session)];
235
235
  case 1:
236
236
  ret = _a.sent();
237
237
  return [2 /*return*/, ret];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.19",
3
+ "version": "2.1.20",
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",
@@ -1,5 +1,5 @@
1
1
  import moment from "moment"
2
- import mongoose from "mongoose"
2
+ import mongoose, { ClientSession } from "mongoose"
3
3
  import { dbCollation } from "../configuration/Environment"
4
4
  import { Pagination, SearchResponse } from "../types/SearchResponse"
5
5
  import { isEmpty, isNotEmpty } from "../utils/Utils"
@@ -143,7 +143,7 @@ abstract class SearchFlow {
143
143
  .populate(params.populate)
144
144
  }
145
145
 
146
- public async sumBy(model: mongoose.Model<any>, _sum: any, _by: any): Promise<any[]> {
146
+ public async sumBy(model: mongoose.Model<any>, _sum: any, _by: any, session?: ClientSession): Promise<any[]> {
147
147
  const ret = await model.aggregate(
148
148
  [
149
149
  {
@@ -157,7 +157,7 @@ abstract class SearchFlow {
157
157
  }
158
158
  }
159
159
  ]
160
- )
160
+ ).session(session!)
161
161
  return ret
162
162
  }
163
163