c2-mongoose 2.1.139 → 2.1.141
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 +2 -3
- package/dist/flow/SearchFlow.js +19 -8
- package/package.json +1 -1
- package/src/flow/SearchFlow.ts +33 -7
|
@@ -15,9 +15,8 @@ declare abstract class SearchFlow {
|
|
|
15
15
|
[key: string]: number;
|
|
16
16
|
} | undefined;
|
|
17
17
|
constructor(params: any);
|
|
18
|
-
buildProjections():
|
|
19
|
-
|
|
20
|
-
} | undefined;
|
|
18
|
+
buildProjections(): any;
|
|
19
|
+
buildProjectionNested(projectCurrent: any, field: string, include: boolean): any;
|
|
21
20
|
buildPopulate(): any;
|
|
22
21
|
buildPopulateArray(): void;
|
|
23
22
|
buildPath(target: string, nested?: string): any;
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -72,19 +72,30 @@ var SearchFlow = /** @class */ (function () {
|
|
|
72
72
|
return undefined;
|
|
73
73
|
}
|
|
74
74
|
var projection = {};
|
|
75
|
-
var found = false;
|
|
76
75
|
for (var _i = 0, _a = this.select; _i < _a.length; _i++) {
|
|
77
76
|
var field = _a[_i];
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
77
|
+
var include = field.startsWith("-") ? false : true;
|
|
78
|
+
field = field.replace("-", "");
|
|
79
|
+
projection = __assign(__assign({}, projection), this.buildProjectionNested({}, field, include));
|
|
80
|
+
// if (field.startsWith("-")) {
|
|
81
|
+
// field = field.substring(1)
|
|
82
|
+
// projection[field] = 0;
|
|
83
|
+
// } else {
|
|
84
|
+
// projection[field] = 1;
|
|
85
|
+
// }
|
|
85
86
|
}
|
|
86
87
|
return projection;
|
|
87
88
|
};
|
|
89
|
+
SearchFlow.prototype.buildProjectionNested = function (projectCurrent, field, include) {
|
|
90
|
+
// var projectionAux: { [key: string]: any } = {}
|
|
91
|
+
var _a = field.split('.'), first = _a[0], rest = _a.slice(1);
|
|
92
|
+
if (rest.length === 0) {
|
|
93
|
+
projectCurrent[first] = include ? 1 : 0;
|
|
94
|
+
return projectCurrent;
|
|
95
|
+
}
|
|
96
|
+
projectCurrent[first] = __assign(__assign({}, projectCurrent[first]), this.buildProjectionNested({}, rest.join("."), include));
|
|
97
|
+
return projectCurrent;
|
|
98
|
+
};
|
|
88
99
|
SearchFlow.prototype.buildPopulate = function () {
|
|
89
100
|
if ((0, Utils_1.isEmpty)(this.populate)) {
|
|
90
101
|
return;
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -35,20 +35,46 @@ abstract class SearchFlow {
|
|
|
35
35
|
return undefined
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
let projection:
|
|
39
|
-
let found = false
|
|
38
|
+
let projection: any = {}
|
|
40
39
|
for (var field of this.select) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
let include = field.startsWith("-") ? false : true
|
|
41
|
+
field = field.replace("-", "")
|
|
42
|
+
projection = {
|
|
43
|
+
...projection,
|
|
44
|
+
...this.buildProjectionNested({}, field, include)
|
|
46
45
|
}
|
|
46
|
+
// if (field.startsWith("-")) {
|
|
47
|
+
// field = field.substring(1)
|
|
48
|
+
// projection[field] = 0;
|
|
49
|
+
// } else {
|
|
50
|
+
// projection[field] = 1;
|
|
51
|
+
// }
|
|
47
52
|
|
|
48
53
|
}
|
|
49
54
|
return projection;
|
|
50
55
|
}
|
|
51
56
|
|
|
57
|
+
buildProjectionNested(projectCurrent: any, field: string, include: boolean) {
|
|
58
|
+
// var projectionAux: { [key: string]: any } = {}
|
|
59
|
+
let [first, ...rest] = field.split('.')
|
|
60
|
+
|
|
61
|
+
if (rest.length === 0) {
|
|
62
|
+
projectCurrent[first] = include ? 1 : 0
|
|
63
|
+
return projectCurrent
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
projectCurrent[first] = {
|
|
67
|
+
...projectCurrent[first],
|
|
68
|
+
...this.buildProjectionNested({}, rest.join("."), include)
|
|
69
|
+
}
|
|
70
|
+
return projectCurrent
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
52
78
|
public buildPopulate(): any {
|
|
53
79
|
if (isEmpty(this.populate)) {
|
|
54
80
|
return
|