c2-mongoose 2.1.183 → 2.1.185
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 +13 -0
- package/dist/flow/SearchFlow.js +5 -0
- package/dist/utils/Utils.js +3 -0
- package/package.json +1 -1
- package/src/flow/C2Flow.ts +13 -2
- package/src/flow/SearchFlow.ts +7 -1
- package/src/utils/Utils.ts +3 -0
package/dist/flow/C2Flow.js
CHANGED
|
@@ -52,6 +52,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
var Logger_1 = require("../model/Logger");
|
|
54
54
|
var BuildLogFlowItem_1 = __importDefault(require("./item/BuildLogFlowItem"));
|
|
55
|
+
var Utils_1 = require("../utils/Utils");
|
|
55
56
|
var C2Flow = /** @class */ (function () {
|
|
56
57
|
function C2Flow(repository) {
|
|
57
58
|
this.repository = repository;
|
|
@@ -105,12 +106,18 @@ var C2Flow = /** @class */ (function () {
|
|
|
105
106
|
case 1:
|
|
106
107
|
dataAfter = _a.sent();
|
|
107
108
|
if (options.logger === false) {
|
|
109
|
+
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
110
|
+
return [2 /*return*/, dataAfter];
|
|
111
|
+
}
|
|
108
112
|
return [2 /*return*/, dataAfter._doc];
|
|
109
113
|
}
|
|
110
114
|
log = BuildLogFlowItem_1.default.build(options, __assign({ _id: _id }, data), Logger_1.TypeOfOperation.UPDATE, this.repository);
|
|
111
115
|
return [4 /*yield*/, global.LoggerRepository.create([log], { session: options.session })];
|
|
112
116
|
case 2:
|
|
113
117
|
_a.sent();
|
|
118
|
+
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
119
|
+
return [2 /*return*/, dataAfter];
|
|
120
|
+
}
|
|
114
121
|
return [2 /*return*/, dataAfter._doc];
|
|
115
122
|
}
|
|
116
123
|
});
|
|
@@ -125,12 +132,18 @@ var C2Flow = /** @class */ (function () {
|
|
|
125
132
|
case 1:
|
|
126
133
|
dataAfter = _a.sent();
|
|
127
134
|
if (options.logger === false) {
|
|
135
|
+
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
136
|
+
return [2 /*return*/, dataAfter];
|
|
137
|
+
}
|
|
128
138
|
return [2 /*return*/, dataAfter._doc];
|
|
129
139
|
}
|
|
130
140
|
log = BuildLogFlowItem_1.default.build(options, __assign({ _id: dataAfter._id }, data), Logger_1.TypeOfOperation.UPDATE, this.repository);
|
|
131
141
|
return [4 /*yield*/, global.LoggerRepository.create([log], { session: options.session })];
|
|
132
142
|
case 2:
|
|
133
143
|
_a.sent();
|
|
144
|
+
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
145
|
+
return [2 /*return*/, dataAfter];
|
|
146
|
+
}
|
|
134
147
|
return [2 /*return*/, dataAfter._doc];
|
|
135
148
|
}
|
|
136
149
|
});
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -498,6 +498,11 @@ var SearchFlow = /** @class */ (function () {
|
|
|
498
498
|
condition[fieldName] = _this.buildRegex(value); //{ $regex: value as any, $options: 'i' }
|
|
499
499
|
filters.$and.push(condition);
|
|
500
500
|
}
|
|
501
|
+
else if (key.endsWith('NotExist')) {
|
|
502
|
+
var fieldName = key.replace('NotExist', '');
|
|
503
|
+
condition[fieldName] = { $exists: false };
|
|
504
|
+
filters.$and.push(condition);
|
|
505
|
+
}
|
|
501
506
|
else {
|
|
502
507
|
if (!Array.isArray(value)) {
|
|
503
508
|
condition[key] = value;
|
package/dist/utils/Utils.js
CHANGED
package/package.json
CHANGED
package/src/flow/C2Flow.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ILogger, TypeOfOperation } from "../model/Logger"
|
|
|
4
4
|
import { Options } from "../types/Options"
|
|
5
5
|
import BuildLogFlowItem from "./item/BuildLogFlowItem"
|
|
6
6
|
import SearchFlow from "./SearchFlow"
|
|
7
|
+
import { isEmpty } from "../utils/Utils"
|
|
7
8
|
|
|
8
9
|
class C2Flow<D> {
|
|
9
10
|
|
|
@@ -43,12 +44,17 @@ class C2Flow<D> {
|
|
|
43
44
|
let dataAfter = await this.repository.findByIdAndUpdate(_id, data, { returnDocument: 'after', session: options.session })
|
|
44
45
|
|
|
45
46
|
if (options.logger === false) {
|
|
47
|
+
if (isEmpty(dataAfter)) {
|
|
48
|
+
return dataAfter
|
|
49
|
+
}
|
|
46
50
|
return dataAfter._doc
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
let log: Partial<ILogger> = BuildLogFlowItem.build(options, { _id, ...data }, TypeOfOperation.UPDATE, this.repository)
|
|
50
54
|
await (global as any).LoggerRepository.create([log], { session: options.session })
|
|
51
|
-
|
|
55
|
+
if (isEmpty(dataAfter)) {
|
|
56
|
+
return dataAfter
|
|
57
|
+
}
|
|
52
58
|
return dataAfter._doc
|
|
53
59
|
}
|
|
54
60
|
|
|
@@ -56,12 +62,17 @@ class C2Flow<D> {
|
|
|
56
62
|
let dataAfter = await this.repository.findOneAndUpdate(searcher.filters, data, { session: options.session })
|
|
57
63
|
|
|
58
64
|
if (options.logger === false) {
|
|
65
|
+
if (isEmpty(dataAfter)) {
|
|
66
|
+
return dataAfter
|
|
67
|
+
}
|
|
59
68
|
return dataAfter._doc
|
|
60
69
|
}
|
|
61
70
|
|
|
62
71
|
let log: Partial<ILogger> = BuildLogFlowItem.build(options, { _id: dataAfter._id, ...data }, TypeOfOperation.UPDATE, this.repository)
|
|
63
72
|
await (global as any).LoggerRepository.create([log], { session: options.session })
|
|
64
|
-
|
|
73
|
+
if (isEmpty(dataAfter)) {
|
|
74
|
+
return dataAfter
|
|
75
|
+
}
|
|
65
76
|
return dataAfter._doc
|
|
66
77
|
}
|
|
67
78
|
|
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -447,7 +447,13 @@ abstract class SearchFlow {
|
|
|
447
447
|
var fieldName = key.replace('Like', '')
|
|
448
448
|
condition[fieldName] = this.buildRegex(value as string) //{ $regex: value as any, $options: 'i' }
|
|
449
449
|
filters.$and.push(condition)
|
|
450
|
-
} else {
|
|
450
|
+
} else if (key.endsWith('NotExist')) {
|
|
451
|
+
var fieldName = key.replace('NotExist', '')
|
|
452
|
+
condition[fieldName] = { $exists: false }
|
|
453
|
+
filters.$and.push(condition)
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
else {
|
|
451
457
|
if (!Array.isArray(value)) {
|
|
452
458
|
condition[key] = value
|
|
453
459
|
} else {
|