c2-mongoose 2.1.33 → 2.1.35
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: any, fieldToGroup: any, addToSet
|
|
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
|
{
|
|
@@ -258,14 +258,14 @@ var SearchFlow = /** @class */ (function () {
|
|
|
258
258
|
momentValue.hour(0);
|
|
259
259
|
momentValue.minute(0);
|
|
260
260
|
momentValue.second(0);
|
|
261
|
-
condition[fieldName] = __assign(__assign({}, condition[fieldName]), { $gte: momentValue.
|
|
261
|
+
condition[fieldName] = __assign(__assign({}, condition[fieldName]), { $gte: momentValue.format("YYYY-MM-DD HH:mm") });
|
|
262
262
|
}
|
|
263
263
|
if ((0, Utils_1.isNotEmpty)(values[1])) {
|
|
264
264
|
var momentValue = (0, moment_1.default)(values[1]);
|
|
265
265
|
momentValue.hour(23);
|
|
266
266
|
momentValue.minute(59);
|
|
267
267
|
momentValue.second(59);
|
|
268
|
-
condition[fieldName] = __assign(__assign({}, condition[fieldName]), { $lte: momentValue.
|
|
268
|
+
condition[fieldName] = __assign(__assign({}, condition[fieldName]), { $lte: momentValue.format("YYYY-MM-DD HH:mm") });
|
|
269
269
|
}
|
|
270
270
|
filters.$and.push(condition);
|
|
271
271
|
}
|
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: any, fieldToGroup: any, addToSet
|
|
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
|
{
|
|
@@ -176,7 +176,7 @@ abstract class SearchFlow {
|
|
|
176
176
|
momentValue.second(0)
|
|
177
177
|
condition[fieldName] = {
|
|
178
178
|
...condition[fieldName],
|
|
179
|
-
$gte: momentValue.
|
|
179
|
+
$gte: momentValue.format("YYYY-MM-DD HH:mm")
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
@@ -187,7 +187,7 @@ abstract class SearchFlow {
|
|
|
187
187
|
momentValue.second(59)
|
|
188
188
|
condition[fieldName] = {
|
|
189
189
|
...condition[fieldName],
|
|
190
|
-
$lte: momentValue.
|
|
190
|
+
$lte: momentValue.format("YYYY-MM-DD HH:mm")
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
filters.$and.push(condition)
|