c2-mongoose 2.1.32 → 2.1.34
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
CHANGED
|
@@ -15,6 +15,6 @@ declare class CrudFlow<D> {
|
|
|
15
15
|
getOne(model: D, params?: any): Promise<D>;
|
|
16
16
|
get(id: string, pop?: string, sel?: string, session?: ClientSession): Promise<D>;
|
|
17
17
|
getById(id: string, session?: ClientSession): Promise<Partial<D>>;
|
|
18
|
-
sumBy(fieldToSum:
|
|
18
|
+
sumBy(fieldToSum: any, fieldToGroup: any, addToSet?: any): Promise<any>;
|
|
19
19
|
}
|
|
20
20
|
export default CrudFlow;
|
|
@@ -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,
|
|
24
|
+
sumBy(model: mongoose.Model<any>, _sum: any, _by: any, items?: any, session?: ClientSession): Promise<any[]>;
|
|
25
25
|
buildDefaultFilters(objectSearch: any): any;
|
|
26
26
|
addFilterModel(model: any, filters: any): void;
|
|
27
27
|
}
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -210,8 +210,8 @@ var SearchFlow = /** @class */ (function () {
|
|
|
210
210
|
});
|
|
211
211
|
});
|
|
212
212
|
};
|
|
213
|
-
SearchFlow.prototype.sumBy = function (model, _sum, _by,
|
|
214
|
-
if (
|
|
213
|
+
SearchFlow.prototype.sumBy = function (model, _sum, _by, items, session) {
|
|
214
|
+
if (items === void 0) { items = undefined; }
|
|
215
215
|
return __awaiter(this, void 0, void 0, function () {
|
|
216
216
|
var sort, ret;
|
|
217
217
|
return __generator(this, function (_a) {
|
|
@@ -227,7 +227,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
227
227
|
_id: _by,
|
|
228
228
|
totalValue: { "$sum": _sum },
|
|
229
229
|
count: { "$sum": 1 },
|
|
230
|
-
items:
|
|
230
|
+
items: items
|
|
231
231
|
}
|
|
232
232
|
},
|
|
233
233
|
{
|
package/package.json
CHANGED
package/src/flow/CrudFlow.ts
CHANGED
|
@@ -65,7 +65,7 @@ class CrudFlow<D> {
|
|
|
65
65
|
return data as D
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
public async sumBy(fieldToSum:
|
|
68
|
+
public async sumBy(fieldToSum: any, fieldToGroup: any, addToSet?: any): Promise<any> {
|
|
69
69
|
return await this.search.sumBy(this.repository, fieldToSum, fieldToGroup, addToSet)
|
|
70
70
|
}
|
|
71
71
|
}
|
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -134,7 +134,7 @@ abstract class SearchFlow {
|
|
|
134
134
|
.populate(params.populate)
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
public async sumBy(model: mongoose.Model<any>, _sum: any, _by: any,
|
|
137
|
+
public async sumBy(model: mongoose.Model<any>, _sum: any, _by: any, items: any = undefined, session?: ClientSession): Promise<any[]> {
|
|
138
138
|
const sort = this.buildOrdenation()
|
|
139
139
|
const ret = await model.aggregate(
|
|
140
140
|
[
|
|
@@ -146,7 +146,7 @@ abstract class SearchFlow {
|
|
|
146
146
|
_id: _by,
|
|
147
147
|
totalValue: { "$sum": _sum },
|
|
148
148
|
count: { "$sum": 1 },
|
|
149
|
-
items
|
|
149
|
+
items
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
152
|
{
|