c2-mongoose 2.1.268 → 2.1.270
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.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare class C2Flow<D> {
|
|
|
8
8
|
createMany(data: Partial<D>[], options: Partial<Options>): Promise<Partial<D>[]>;
|
|
9
9
|
updateById(_id: Types.ObjectId, data: Partial<D>, options: Partial<Options>): Promise<Partial<D>>;
|
|
10
10
|
updateByModel(searcher: SearchFlow, data: Partial<D>, options: Partial<Options>): Promise<Partial<D>>;
|
|
11
|
-
updateByFilters(filters: any, data:
|
|
11
|
+
updateByFilters(filters: any, data: D, options: Partial<Options>): Promise<any>;
|
|
12
12
|
updateMany(searcher: SearchFlow, data: D, options: Options): Promise<any>;
|
|
13
13
|
deleteById(_id: Types.ObjectId, options: Partial<Options>): Promise<void>;
|
|
14
14
|
deleteByModel(searcher: SearchFlow, options: Partial<Options>): Promise<void>;
|
package/dist/flow/C2Flow.js
CHANGED
|
@@ -160,26 +160,26 @@ var C2Flow = /** @class */ (function () {
|
|
|
160
160
|
var dataAfter, log;
|
|
161
161
|
return __generator(this, function (_a) {
|
|
162
162
|
switch (_a.label) {
|
|
163
|
-
case 0: return [4 /*yield*/, this.repository.
|
|
163
|
+
case 0: return [4 /*yield*/, this.repository.updateMany(filters, data, { returnDocument: 'after', session: options.session })];
|
|
164
164
|
case 1:
|
|
165
165
|
dataAfter = _a.sent();
|
|
166
166
|
if (options.logger === false) {
|
|
167
167
|
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
168
168
|
return [2 /*return*/, dataAfter];
|
|
169
169
|
}
|
|
170
|
-
return [2 /*return*/, dataAfter
|
|
170
|
+
return [2 /*return*/, dataAfter];
|
|
171
171
|
}
|
|
172
172
|
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
173
173
|
return [2 /*return*/, dataAfter];
|
|
174
174
|
}
|
|
175
|
-
log = BuildLogFlowItem_1.default.build(options, __assign({
|
|
175
|
+
log = BuildLogFlowItem_1.default.build(options, __assign({ filters: filters }, data), Logger_1.TypeOfOperation.UPDATE, this.repository);
|
|
176
176
|
return [4 /*yield*/, global.LoggerRepository.create([log], { session: options.session })];
|
|
177
177
|
case 2:
|
|
178
178
|
_a.sent();
|
|
179
179
|
if ((0, Utils_1.isEmpty)(dataAfter)) {
|
|
180
180
|
return [2 /*return*/, dataAfter];
|
|
181
181
|
}
|
|
182
|
-
return [2 /*return*/, dataAfter
|
|
182
|
+
return [2 /*return*/, dataAfter];
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
185
|
});
|
|
@@ -67,6 +67,7 @@ var BuildSelectSingleFlowItem_1 = __importDefault(require("./item/BuildSelectSin
|
|
|
67
67
|
var SearcherFlow = /** @class */ (function () {
|
|
68
68
|
function SearcherFlow(repository) {
|
|
69
69
|
this.searchText = "";
|
|
70
|
+
this.searchTextFields = [];
|
|
70
71
|
this.orderSense = "desc";
|
|
71
72
|
this.orderBy = "_id";
|
|
72
73
|
this.page = 1;
|
|
@@ -213,7 +214,7 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
213
214
|
SearcherFlow.prototype.buildDefaultFilters = function (objectSearch) {
|
|
214
215
|
var _this = this;
|
|
215
216
|
// Recuperar todos os campos do tipo String
|
|
216
|
-
var camposString = this.extractFieldsOfType(this.model.schema, 'String');
|
|
217
|
+
var camposString = (0, Utils_1.isEmpty)(this.searchTextFields) ? this.extractFieldsOfType(this.model.schema, 'String') : this.searchTextFields;
|
|
217
218
|
var filters = { $and: [] };
|
|
218
219
|
Object.entries(objectSearch).forEach(function (_a) {
|
|
219
220
|
var _b, _c, _d;
|
|
@@ -235,6 +236,7 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
235
236
|
'model',
|
|
236
237
|
'select',
|
|
237
238
|
'searchText',
|
|
239
|
+
'searchTextFields',
|
|
238
240
|
'sort',
|
|
239
241
|
'isPageable',
|
|
240
242
|
'searchPageable'
|
package/package.json
CHANGED
package/src/flow/C2Flow.ts
CHANGED
|
@@ -83,26 +83,26 @@ class C2Flow<D> {
|
|
|
83
83
|
return dataAfter._doc
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
async updateByFilters(filters: any, data:
|
|
87
|
-
let dataAfter = await this.repository.
|
|
86
|
+
async updateByFilters(filters: any, data: D, options: Partial<Options>): Promise<any> {
|
|
87
|
+
let dataAfter = await this.repository.updateMany(filters, data as any, { returnDocument: 'after', session: options.session })
|
|
88
88
|
|
|
89
89
|
if (options.logger === false) {
|
|
90
90
|
if (isEmpty(dataAfter)) {
|
|
91
91
|
return dataAfter
|
|
92
92
|
}
|
|
93
|
-
return dataAfter
|
|
93
|
+
return dataAfter
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
if (isEmpty(dataAfter)) {
|
|
97
97
|
return dataAfter
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
let log: Partial<ILogger> = BuildLogFlowItem.build(options, {
|
|
100
|
+
let log: Partial<ILogger> = BuildLogFlowItem.build(options, { filters, ...data }, TypeOfOperation.UPDATE, this.repository)
|
|
101
101
|
await (global as any).LoggerRepository.create([log], { session: options.session })
|
|
102
102
|
if (isEmpty(dataAfter)) {
|
|
103
103
|
return dataAfter
|
|
104
104
|
}
|
|
105
|
-
return dataAfter
|
|
105
|
+
return dataAfter
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
async updateMany(searcher: SearchFlow, data: D, options: Options): Promise<any> {
|
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -17,6 +17,7 @@ class SearcherFlow<D> {
|
|
|
17
17
|
|
|
18
18
|
[key: string]: any
|
|
19
19
|
public searchText: string = ""
|
|
20
|
+
public searchTextFields: string[] = []
|
|
20
21
|
public orderSense: string = "desc"
|
|
21
22
|
public orderBy: string = "_id"
|
|
22
23
|
public page: number = 1
|
|
@@ -175,7 +176,7 @@ class SearcherFlow<D> {
|
|
|
175
176
|
public buildDefaultFilters(objectSearch: any) {
|
|
176
177
|
|
|
177
178
|
// Recuperar todos os campos do tipo String
|
|
178
|
-
const camposString = this.extractFieldsOfType(this.model.schema, 'String')
|
|
179
|
+
const camposString = isEmpty(this.searchTextFields) ? this.extractFieldsOfType(this.model.schema, 'String') : this.searchTextFields
|
|
179
180
|
|
|
180
181
|
|
|
181
182
|
let filters = { $and: [] } as any
|
|
@@ -197,6 +198,7 @@ class SearcherFlow<D> {
|
|
|
197
198
|
'model',
|
|
198
199
|
'select',
|
|
199
200
|
'searchText',
|
|
201
|
+
'searchTextFields',
|
|
200
202
|
'sort',
|
|
201
203
|
'isPageable',
|
|
202
204
|
'searchPageable'].includes(key)) {
|