c2-mongoose 2.1.39 → 2.1.40

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.
@@ -11,6 +11,7 @@ declare class CrudFlow<D> {
11
11
  deleteMany(conditions: {}, session?: any): Promise<void>;
12
12
  update(id: string, data: D, session?: any): Promise<D>;
13
13
  updateAny(id: string, data: any, session?: any): Promise<D>;
14
+ updateByModel(filter: any, data: any, params: any): Promise<D>;
14
15
  find(): Promise<SearchResponse<D>>;
15
16
  getOne(model: D, params?: any): Promise<D>;
16
17
  get(id: string, pop?: string, sel?: string, session?: ClientSession): Promise<D>;
@@ -110,6 +110,19 @@ var CrudFlow = /** @class */ (function () {
110
110
  });
111
111
  });
112
112
  };
113
+ CrudFlow.prototype.updateByModel = function (filter, data, params) {
114
+ return __awaiter(this, void 0, void 0, function () {
115
+ var dataAfter;
116
+ return __generator(this, function (_a) {
117
+ switch (_a.label) {
118
+ case 0: return [4 /*yield*/, this.repository.findOneAndUpdate(filter, data, params)];
119
+ case 1:
120
+ dataAfter = _a.sent();
121
+ return [2 /*return*/, dataAfter];
122
+ }
123
+ });
124
+ });
125
+ };
113
126
  CrudFlow.prototype.find = function () {
114
127
  return __awaiter(this, void 0, void 0, function () {
115
128
  return __generator(this, function (_a) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.39",
3
+ "version": "2.1.40",
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",
@@ -39,6 +39,11 @@ class CrudFlow<D> {
39
39
  return dataAfter as D
40
40
  }
41
41
 
42
+ public async updateByModel(filter: any, data: any, params: any): Promise<D> {
43
+ const dataAfter = await this.repository.findOneAndUpdate(filter, data, params)
44
+ return dataAfter as D
45
+ }
46
+
42
47
  public async find(): Promise<SearchResponse<D>> {
43
48
  return await this.search.search(this.repository)
44
49
  }