c2-mongoose 2.1.270 → 2.1.275
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/C2Flow.js +6 -6
- package/dist/flow/SearcherFlow.js +20 -1
- package/package.json +1 -1
- package/src/flow/C2Flow.ts +6 -6
- package/src/flow/SearcherFlow.ts +26 -1
package/dist/flow/C2Flow.js
CHANGED
|
@@ -85,7 +85,7 @@ var C2Flow = /** @class */ (function () {
|
|
|
85
85
|
case 0: return [4 /*yield*/, this.repository.create(data, { session: options.session })];
|
|
86
86
|
case 1:
|
|
87
87
|
dataAfter = _a.sent();
|
|
88
|
-
if (options.logger === false) {
|
|
88
|
+
if (options.logger === false || (0, Utils_1.isEmpty)(dataAfter)) {
|
|
89
89
|
return [2 /*return*/, dataAfter];
|
|
90
90
|
}
|
|
91
91
|
log = BuildLogFlowItem_1.default.build(options, dataAfter[0]._doc, Logger_1.TypeOfOperation.CREATE, this.repository);
|
|
@@ -109,7 +109,7 @@ var C2Flow = /** @class */ (function () {
|
|
|
109
109
|
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
110
110
|
return [2 /*return*/, dataAfter];
|
|
111
111
|
}
|
|
112
|
-
return [2 /*return*/, dataAfter._doc];
|
|
112
|
+
return [2 /*return*/, dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter._doc];
|
|
113
113
|
}
|
|
114
114
|
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
115
115
|
return [2 /*return*/, dataAfter];
|
|
@@ -121,7 +121,7 @@ var C2Flow = /** @class */ (function () {
|
|
|
121
121
|
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
122
122
|
return [2 /*return*/, dataAfter];
|
|
123
123
|
}
|
|
124
|
-
return [2 /*return*/, dataAfter._doc];
|
|
124
|
+
return [2 /*return*/, dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter._doc];
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
});
|
|
@@ -138,7 +138,7 @@ var C2Flow = /** @class */ (function () {
|
|
|
138
138
|
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
139
139
|
return [2 /*return*/, dataAfter];
|
|
140
140
|
}
|
|
141
|
-
return [2 /*return*/, dataAfter._doc];
|
|
141
|
+
return [2 /*return*/, dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter._doc];
|
|
142
142
|
}
|
|
143
143
|
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
144
144
|
return [2 /*return*/, dataAfter];
|
|
@@ -150,7 +150,7 @@ var C2Flow = /** @class */ (function () {
|
|
|
150
150
|
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
151
151
|
return [2 /*return*/, dataAfter];
|
|
152
152
|
}
|
|
153
|
-
return [2 /*return*/, dataAfter._doc];
|
|
153
|
+
return [2 /*return*/, dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter._doc];
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
});
|
|
@@ -224,7 +224,7 @@ var C2Flow = /** @class */ (function () {
|
|
|
224
224
|
if (options.logger === false) {
|
|
225
225
|
return [2 /*return*/];
|
|
226
226
|
}
|
|
227
|
-
log = BuildLogFlowItem_1.default.build(options, __assign({ _id: _id }, dataAfter._doc), Logger_1.TypeOfOperation.DELETE, this.repository);
|
|
227
|
+
log = BuildLogFlowItem_1.default.build(options, __assign({ _id: _id }, dataAfter === null || dataAfter === void 0 ? void 0 : dataAfter._doc), Logger_1.TypeOfOperation.DELETE, this.repository);
|
|
228
228
|
return [4 /*yield*/, global.LoggerRepository.create([log], { session: options.session })];
|
|
229
229
|
case 2:
|
|
230
230
|
_a.sent();
|
|
@@ -252,7 +252,7 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
252
252
|
if (value === 'false') {
|
|
253
253
|
value = false;
|
|
254
254
|
}
|
|
255
|
-
if (key.endsWith('DateRange')
|
|
255
|
+
if (key.endsWith('DateRange')) {
|
|
256
256
|
var fieldName = key.replace('Range', '');
|
|
257
257
|
var values = value;
|
|
258
258
|
if ((0, Utils_1.isNotEmpty)(values[0])) {
|
|
@@ -271,6 +271,25 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
271
271
|
}
|
|
272
272
|
filters.$and.push(condition);
|
|
273
273
|
}
|
|
274
|
+
else if (key.endsWith('DateTimeRange')) {
|
|
275
|
+
var fieldName = key.replace('Range', '');
|
|
276
|
+
var values = value;
|
|
277
|
+
if ((0, Utils_1.isNotEmpty)(values[0])) {
|
|
278
|
+
var momentValue = (0, moment_1.default)(values[0]);
|
|
279
|
+
// momentValue.hour(0)
|
|
280
|
+
// momentValue.minute(0)
|
|
281
|
+
// momentValue.second(0)
|
|
282
|
+
condition[fieldName] = __assign(__assign({}, condition[fieldName]), { $gte: momentValue.tz('America/Sao_Paulo', true).toDate() });
|
|
283
|
+
}
|
|
284
|
+
if ((0, Utils_1.isNotEmpty)(values[1])) {
|
|
285
|
+
var momentValue = (0, moment_1.default)(values[1]);
|
|
286
|
+
// momentValue.hour(23)
|
|
287
|
+
// momentValue.minute(59)
|
|
288
|
+
// momentValue.second(59)
|
|
289
|
+
condition[fieldName] = __assign(__assign({}, condition[fieldName]), { $lte: momentValue.tz('America/Sao_Paulo', true).toDate() });
|
|
290
|
+
}
|
|
291
|
+
filters.$and.push(condition);
|
|
292
|
+
}
|
|
274
293
|
else if (key.endsWith('Like')) {
|
|
275
294
|
var fieldName = key.replace('Like', '');
|
|
276
295
|
condition[fieldName] = _this.buildRegex(value); //{ $regex: value as any, $options: 'i' }
|
package/package.json
CHANGED
package/src/flow/C2Flow.ts
CHANGED
|
@@ -30,7 +30,7 @@ class C2Flow<D> {
|
|
|
30
30
|
async createMany(data: Partial<D>[], options: Partial<Options>): Promise<Partial<D>[]> {
|
|
31
31
|
let dataAfter = await this.repository.create(data, { session: options.session })
|
|
32
32
|
|
|
33
|
-
if (options.logger === false) {
|
|
33
|
+
if (options.logger === false || isEmpty(dataAfter)) {
|
|
34
34
|
return dataAfter
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -47,7 +47,7 @@ class C2Flow<D> {
|
|
|
47
47
|
if (isEmpty(dataAfter)) {
|
|
48
48
|
return dataAfter
|
|
49
49
|
}
|
|
50
|
-
return dataAfter
|
|
50
|
+
return dataAfter?._doc
|
|
51
51
|
}
|
|
52
52
|
if (isEmpty(dataAfter)) {
|
|
53
53
|
return dataAfter
|
|
@@ -58,7 +58,7 @@ class C2Flow<D> {
|
|
|
58
58
|
if (isEmpty(dataAfter)) {
|
|
59
59
|
return dataAfter
|
|
60
60
|
}
|
|
61
|
-
return dataAfter
|
|
61
|
+
return dataAfter?._doc
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
async updateByModel(searcher: SearchFlow, data: Partial<D>, options: Partial<Options>): Promise<Partial<D>> {
|
|
@@ -68,7 +68,7 @@ class C2Flow<D> {
|
|
|
68
68
|
if (isEmpty(dataAfter)) {
|
|
69
69
|
return dataAfter
|
|
70
70
|
}
|
|
71
|
-
return dataAfter
|
|
71
|
+
return dataAfter?._doc
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
if (isEmpty(dataAfter)) {
|
|
@@ -80,7 +80,7 @@ class C2Flow<D> {
|
|
|
80
80
|
if (isEmpty(dataAfter)) {
|
|
81
81
|
return dataAfter
|
|
82
82
|
}
|
|
83
|
-
return dataAfter
|
|
83
|
+
return dataAfter?._doc
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
async updateByFilters(filters: any, data: D, options: Partial<Options>): Promise<any> {
|
|
@@ -135,7 +135,7 @@ class C2Flow<D> {
|
|
|
135
135
|
return
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
let log: Partial<ILogger> = BuildLogFlowItem.build(options, { _id, ...dataAfter
|
|
138
|
+
let log: Partial<ILogger> = BuildLogFlowItem.build(options, { _id, ...dataAfter?._doc }, TypeOfOperation.DELETE, this.repository)
|
|
139
139
|
await (global as any).LoggerRepository.create([log], { session: options.session })
|
|
140
140
|
}
|
|
141
141
|
|
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -217,7 +217,7 @@ class SearcherFlow<D> {
|
|
|
217
217
|
value = false
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
if (key.endsWith('DateRange')
|
|
220
|
+
if (key.endsWith('DateRange')) {
|
|
221
221
|
var fieldName = key.replace('Range', '')
|
|
222
222
|
var values = value as any
|
|
223
223
|
if (isNotEmpty(values[0])) {
|
|
@@ -242,6 +242,31 @@ class SearcherFlow<D> {
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
filters.$and.push(condition)
|
|
245
|
+
}else if (key.endsWith('DateTimeRange')) {
|
|
246
|
+
var fieldName = key.replace('Range', '')
|
|
247
|
+
var values = value as any
|
|
248
|
+
if (isNotEmpty(values[0])) {
|
|
249
|
+
var momentValue = moment(values[0])
|
|
250
|
+
// momentValue.hour(0)
|
|
251
|
+
// momentValue.minute(0)
|
|
252
|
+
// momentValue.second(0)
|
|
253
|
+
condition[fieldName] = {
|
|
254
|
+
...condition[fieldName],
|
|
255
|
+
$gte: momentValue.tz('America/Sao_Paulo', true).toDate()
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (isNotEmpty(values[1])) {
|
|
260
|
+
var momentValue = moment(values[1])
|
|
261
|
+
// momentValue.hour(23)
|
|
262
|
+
// momentValue.minute(59)
|
|
263
|
+
// momentValue.second(59)
|
|
264
|
+
condition[fieldName] = {
|
|
265
|
+
...condition[fieldName],
|
|
266
|
+
$lte: momentValue.tz('America/Sao_Paulo', true).toDate()
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
filters.$and.push(condition)
|
|
245
270
|
} else if (key.endsWith('Like')) {
|
|
246
271
|
var fieldName = key.replace('Like', '')
|
|
247
272
|
condition[fieldName] = this.buildRegex(value as string) //{ $regex: value as any, $options: 'i' }
|