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.
- package/dist/flow/CrudFlow.d.ts +1 -0
- package/dist/flow/CrudFlow.js +13 -0
- package/package.json +1 -1
- package/src/flow/CrudFlow.ts +5 -0
package/dist/flow/CrudFlow.d.ts
CHANGED
|
@@ -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>;
|
package/dist/flow/CrudFlow.js
CHANGED
|
@@ -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
package/src/flow/CrudFlow.ts
CHANGED
|
@@ -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
|
}
|