c2-mongoose 2.1.142 → 2.1.144
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/SearchFlow.d.ts +0 -1
- package/dist/flow/SearchFlow.js +15 -24
- package/package.json +1 -1
- package/src/flow/SearchFlow.ts +8 -27
|
@@ -18,7 +18,6 @@ declare abstract class SearchFlow {
|
|
|
18
18
|
buildProjections(): any;
|
|
19
19
|
buildProjectionNested(projectCurrent: any, field: string, include: boolean): any;
|
|
20
20
|
buildPopulate(): any;
|
|
21
|
-
buildPopulateArray(): void;
|
|
22
21
|
buildPath(target: string, nested?: string): any;
|
|
23
22
|
buildOrdenation(): any;
|
|
24
23
|
buildRegex(searchText: string): RegExp;
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -64,7 +64,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
64
64
|
this.limit = Number(params.limit || 25);
|
|
65
65
|
this.pageable = params.pageable == false || params.pageable == 'false' ? false : true;
|
|
66
66
|
this.projection = this.buildProjections();
|
|
67
|
-
this.buildPopulate();
|
|
67
|
+
this.populate = this.buildPopulate();
|
|
68
68
|
this.buildOrdenation();
|
|
69
69
|
}
|
|
70
70
|
SearchFlow.prototype.buildProjections = function () {
|
|
@@ -81,7 +81,6 @@ var SearchFlow = /** @class */ (function () {
|
|
|
81
81
|
return projection;
|
|
82
82
|
};
|
|
83
83
|
SearchFlow.prototype.buildProjectionNested = function (projectCurrent, field, include) {
|
|
84
|
-
// var projectionAux: { [key: string]: any } = {}
|
|
85
84
|
var _a = field.split('.'), first = _a[0], rest = _a.slice(1);
|
|
86
85
|
if (rest.length === 0) {
|
|
87
86
|
projectCurrent[first] = include ? 1 : 0;
|
|
@@ -94,22 +93,14 @@ var SearchFlow = /** @class */ (function () {
|
|
|
94
93
|
if ((0, Utils_1.isEmpty)(this.populate)) {
|
|
95
94
|
return;
|
|
96
95
|
}
|
|
97
|
-
if (Array.isArray(this.populate)) {
|
|
98
|
-
return
|
|
99
|
-
}
|
|
100
|
-
var propertiesArray = this.populate.toString().split(',');
|
|
101
|
-
var populates = [];
|
|
102
|
-
for (var _i = 0, propertiesArray_1 = propertiesArray; _i < propertiesArray_1.length; _i++) {
|
|
103
|
-
var property = propertiesArray_1[_i];
|
|
104
|
-
var _a = property.split('.'), first = _a[0], rest = _a.slice(1);
|
|
105
|
-
var nested = rest.join('.');
|
|
106
|
-
populates.push(this.buildPath(first, nested));
|
|
96
|
+
if (!Array.isArray(this.populate)) {
|
|
97
|
+
return;
|
|
107
98
|
}
|
|
108
|
-
this.populate = populates;
|
|
109
|
-
};
|
|
110
|
-
SearchFlow.prototype.buildPopulateArray = function () {
|
|
111
99
|
var populates = [];
|
|
112
100
|
var _loop_1 = function () {
|
|
101
|
+
if (property.include(".")) {
|
|
102
|
+
return "continue";
|
|
103
|
+
}
|
|
113
104
|
var _b = property.split('.'), first = _b[0], rest = _b.slice(1);
|
|
114
105
|
var nested = rest.join('.');
|
|
115
106
|
var populate = this_1.buildPath(first, nested);
|
|
@@ -124,7 +115,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
124
115
|
var property = _a[_i];
|
|
125
116
|
_loop_1();
|
|
126
117
|
}
|
|
127
|
-
|
|
118
|
+
return populates;
|
|
128
119
|
};
|
|
129
120
|
SearchFlow.prototype.buildPath = function (target, nested) {
|
|
130
121
|
if (nested === void 0) { nested = ""; }
|
|
@@ -221,9 +212,9 @@ var SearchFlow = /** @class */ (function () {
|
|
|
221
212
|
};
|
|
222
213
|
SearchFlow.prototype.searchPageable = function (model, options) {
|
|
223
214
|
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
-
var stagesItems, stagesPaging, stagesMetadata, facet, _i, stagesMetadata_2, metadata, result,
|
|
225
|
-
return __generator(this, function (
|
|
226
|
-
switch (
|
|
215
|
+
var stagesItems, stagesPaging, stagesMetadata, facet, _i, stagesMetadata_2, metadata, result, _a, _b, populate, _c, resultAux;
|
|
216
|
+
return __generator(this, function (_d) {
|
|
217
|
+
switch (_d.label) {
|
|
227
218
|
case 0:
|
|
228
219
|
stagesItems = [];
|
|
229
220
|
if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
|
|
@@ -267,18 +258,18 @@ var SearchFlow = /** @class */ (function () {
|
|
|
267
258
|
},
|
|
268
259
|
]).session(options === null || options === void 0 ? void 0 : options.session)];
|
|
269
260
|
case 1:
|
|
270
|
-
result =
|
|
271
|
-
items = result[0].items;
|
|
261
|
+
result = _d.sent();
|
|
272
262
|
if (!((0, Utils_1.isNotEmpty)(this.populate) && Array.isArray(this.populate))) return [3 /*break*/, 5];
|
|
273
263
|
_a = 0, _b = this.populate;
|
|
274
|
-
|
|
264
|
+
_d.label = 2;
|
|
275
265
|
case 2:
|
|
276
266
|
if (!(_a < _b.length)) return [3 /*break*/, 5];
|
|
277
267
|
populate = _b[_a];
|
|
268
|
+
_c = result[0];
|
|
278
269
|
return [4 /*yield*/, model.populate(result[0].items, populate)];
|
|
279
270
|
case 3:
|
|
280
|
-
items =
|
|
281
|
-
|
|
271
|
+
_c.items = _d.sent();
|
|
272
|
+
_d.label = 4;
|
|
282
273
|
case 4:
|
|
283
274
|
_a++;
|
|
284
275
|
return [3 /*break*/, 2];
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -26,7 +26,7 @@ abstract class SearchFlow {
|
|
|
26
26
|
this.limit = Number(params.limit || 25)
|
|
27
27
|
this.pageable = params.pageable == false || params.pageable == 'false' ? false : true
|
|
28
28
|
this.projection = this.buildProjections()
|
|
29
|
-
this.buildPopulate()
|
|
29
|
+
this.populate = this.buildPopulate()
|
|
30
30
|
this.buildOrdenation()
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -49,7 +49,6 @@ abstract class SearchFlow {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
buildProjectionNested(projectCurrent: any, field: string, include: boolean) {
|
|
52
|
-
// var projectionAux: { [key: string]: any } = {}
|
|
53
52
|
let [first, ...rest] = field.split('.')
|
|
54
53
|
|
|
55
54
|
if (rest.length === 0) {
|
|
@@ -64,34 +63,20 @@ abstract class SearchFlow {
|
|
|
64
63
|
return projectCurrent
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
66
|
public buildPopulate(): any {
|
|
73
67
|
if (isEmpty(this.populate)) {
|
|
74
68
|
return
|
|
75
69
|
}
|
|
76
70
|
|
|
77
|
-
if (Array.isArray(this.populate)) {
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
var propertiesArray = (this.populate as string).toString().split(',')
|
|
82
|
-
var populates = [] as any
|
|
83
|
-
for (var property of propertiesArray) {
|
|
84
|
-
let [first, ...rest] = property.split('.')
|
|
85
|
-
let nested = rest.join('.')
|
|
86
|
-
populates.push(this.buildPath(first, nested))
|
|
71
|
+
if (!Array.isArray(this.populate)) {
|
|
72
|
+
return
|
|
87
73
|
}
|
|
88
74
|
|
|
89
|
-
this.populate = populates
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
buildPopulateArray() {
|
|
93
75
|
var populates = [] as any
|
|
94
76
|
for (var property of this.populate) {
|
|
77
|
+
if (property.include(".")) {
|
|
78
|
+
continue
|
|
79
|
+
}
|
|
95
80
|
let [first, ...rest] = property.split('.')
|
|
96
81
|
let nested = rest.join('.')
|
|
97
82
|
let populate = this.buildPath(first, nested)
|
|
@@ -102,7 +87,7 @@ abstract class SearchFlow {
|
|
|
102
87
|
populates.push(populate)
|
|
103
88
|
}
|
|
104
89
|
|
|
105
|
-
|
|
90
|
+
return populates
|
|
106
91
|
}
|
|
107
92
|
|
|
108
93
|
public buildPath(target: string, nested: string = "") {
|
|
@@ -245,8 +230,6 @@ abstract class SearchFlow {
|
|
|
245
230
|
facet[metadata.id] = metadata.conditions
|
|
246
231
|
}
|
|
247
232
|
|
|
248
|
-
|
|
249
|
-
|
|
250
233
|
const result = await model.aggregate(
|
|
251
234
|
[
|
|
252
235
|
{
|
|
@@ -255,11 +238,9 @@ abstract class SearchFlow {
|
|
|
255
238
|
]
|
|
256
239
|
).session(options?.session as ClientSession)
|
|
257
240
|
|
|
258
|
-
var items = result[0].items
|
|
259
|
-
|
|
260
241
|
if (isNotEmpty(this.populate) && Array.isArray(this.populate)) {
|
|
261
242
|
for (var populate of this.populate) {
|
|
262
|
-
items = await model.populate(result[0].items, populate)
|
|
243
|
+
result[0].items = await model.populate(result[0].items, populate)
|
|
263
244
|
}
|
|
264
245
|
}
|
|
265
246
|
|