c2-mongoose 2.1.38 → 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 +2 -1
- package/dist/flow/CrudFlow.js +15 -2
- package/package.json +1 -1
- package/src/flow/CrudFlow.ts +7 -2
package/dist/flow/CrudFlow.d.ts
CHANGED
|
@@ -11,11 +11,12 @@ 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>;
|
|
17
18
|
getById(id: string, session?: ClientSession): Promise<Partial<D>>;
|
|
18
|
-
sumBy(fieldToSum: any, fieldToGroup: any, addToSet?: any): Promise<any>;
|
|
19
|
+
sumBy(fieldToSum: any, fieldToGroup: any, addToSet?: any, session?: ClientSession): Promise<any>;
|
|
19
20
|
sumByAndPaging(fieldToSum: any, fieldToGroup: any, addToSet?: any): Promise<SearchResponse<any>>;
|
|
20
21
|
}
|
|
21
22
|
export default CrudFlow;
|
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) {
|
|
@@ -169,11 +182,11 @@ var CrudFlow = /** @class */ (function () {
|
|
|
169
182
|
});
|
|
170
183
|
});
|
|
171
184
|
};
|
|
172
|
-
CrudFlow.prototype.sumBy = function (fieldToSum, fieldToGroup, addToSet) {
|
|
185
|
+
CrudFlow.prototype.sumBy = function (fieldToSum, fieldToGroup, addToSet, session) {
|
|
173
186
|
return __awaiter(this, void 0, void 0, function () {
|
|
174
187
|
return __generator(this, function (_a) {
|
|
175
188
|
switch (_a.label) {
|
|
176
|
-
case 0: return [4 /*yield*/, this.search.sumBy(this.repository, fieldToSum, fieldToGroup, addToSet)];
|
|
189
|
+
case 0: return [4 /*yield*/, this.search.sumBy(this.repository, fieldToSum, fieldToGroup, addToSet, session)];
|
|
177
190
|
case 1: return [2 /*return*/, _a.sent()];
|
|
178
191
|
}
|
|
179
192
|
});
|
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
|
}
|
|
@@ -65,8 +70,8 @@ class CrudFlow<D> {
|
|
|
65
70
|
return data as D
|
|
66
71
|
}
|
|
67
72
|
|
|
68
|
-
public async sumBy(fieldToSum: any, fieldToGroup: any, addToSet?: any): Promise<any> {
|
|
69
|
-
return await this.search.sumBy(this.repository, fieldToSum, fieldToGroup, addToSet)
|
|
73
|
+
public async sumBy(fieldToSum: any, fieldToGroup: any, addToSet?: any, session?: ClientSession): Promise<any> {
|
|
74
|
+
return await this.search.sumBy(this.repository, fieldToSum, fieldToGroup, addToSet, session)
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
public async sumByAndPaging(fieldToSum: any, fieldToGroup: any, addToSet?: any): Promise<SearchResponse<any>> {
|