c2-mongoose 2.1.192 → 2.1.194
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 +7 -1
- package/package.json +1 -1
- package/src/flow/C2Flow.ts +8 -1
package/dist/flow/C2Flow.js
CHANGED
|
@@ -111,6 +111,9 @@ var C2Flow = /** @class */ (function () {
|
|
|
111
111
|
}
|
|
112
112
|
return [2 /*return*/, dataAfter._doc];
|
|
113
113
|
}
|
|
114
|
+
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
115
|
+
return [2 /*return*/, dataAfter];
|
|
116
|
+
}
|
|
114
117
|
log = BuildLogFlowItem_1.default.build(options, __assign({ _id: _id }, data), Logger_1.TypeOfOperation.UPDATE, this.repository);
|
|
115
118
|
return [4 /*yield*/, global.LoggerRepository.create([log], { session: options.session })];
|
|
116
119
|
case 2:
|
|
@@ -128,7 +131,7 @@ var C2Flow = /** @class */ (function () {
|
|
|
128
131
|
var dataAfter, log;
|
|
129
132
|
return __generator(this, function (_a) {
|
|
130
133
|
switch (_a.label) {
|
|
131
|
-
case 0: return [4 /*yield*/, this.repository.findOneAndUpdate(searcher.filters, data, { session: options.session })];
|
|
134
|
+
case 0: return [4 /*yield*/, this.repository.findOneAndUpdate(searcher.filters, data, { returnDocument: 'after', session: options.session })];
|
|
132
135
|
case 1:
|
|
133
136
|
dataAfter = _a.sent();
|
|
134
137
|
if (options.logger === false) {
|
|
@@ -137,6 +140,9 @@ var C2Flow = /** @class */ (function () {
|
|
|
137
140
|
}
|
|
138
141
|
return [2 /*return*/, dataAfter._doc];
|
|
139
142
|
}
|
|
143
|
+
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
144
|
+
return [2 /*return*/, dataAfter];
|
|
145
|
+
}
|
|
140
146
|
log = BuildLogFlowItem_1.default.build(options, __assign({ _id: dataAfter._id }, data), Logger_1.TypeOfOperation.UPDATE, this.repository);
|
|
141
147
|
return [4 /*yield*/, global.LoggerRepository.create([log], { session: options.session })];
|
|
142
148
|
case 2:
|
package/package.json
CHANGED
package/src/flow/C2Flow.ts
CHANGED
|
@@ -49,6 +49,9 @@ class C2Flow<D> {
|
|
|
49
49
|
}
|
|
50
50
|
return dataAfter._doc
|
|
51
51
|
}
|
|
52
|
+
if (isEmpty(dataAfter)) {
|
|
53
|
+
return dataAfter
|
|
54
|
+
}
|
|
52
55
|
|
|
53
56
|
let log: Partial<ILogger> = BuildLogFlowItem.build(options, { _id, ...data }, TypeOfOperation.UPDATE, this.repository)
|
|
54
57
|
await (global as any).LoggerRepository.create([log], { session: options.session })
|
|
@@ -59,7 +62,7 @@ class C2Flow<D> {
|
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
async updateByModel(searcher: SearchFlow, data: Partial<D>, options: Partial<Options>): Promise<Partial<D>> {
|
|
62
|
-
let dataAfter = await this.repository.findOneAndUpdate(searcher.filters, data, { session: options.session })
|
|
65
|
+
let dataAfter = await this.repository.findOneAndUpdate(searcher.filters, data, { returnDocument: 'after', session: options.session })
|
|
63
66
|
|
|
64
67
|
if (options.logger === false) {
|
|
65
68
|
if (isEmpty(dataAfter)) {
|
|
@@ -68,6 +71,10 @@ class C2Flow<D> {
|
|
|
68
71
|
return dataAfter._doc
|
|
69
72
|
}
|
|
70
73
|
|
|
74
|
+
if (isEmpty(dataAfter)) {
|
|
75
|
+
return dataAfter
|
|
76
|
+
}
|
|
77
|
+
|
|
71
78
|
let log: Partial<ILogger> = BuildLogFlowItem.build(options, { _id: dataAfter._id, ...data }, TypeOfOperation.UPDATE, this.repository)
|
|
72
79
|
await (global as any).LoggerRepository.create([log], { session: options.session })
|
|
73
80
|
if (isEmpty(dataAfter)) {
|