c2-mongoose 2.1.63 → 2.1.64
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 -1
- package/dist/flow/SearchFlow.js +22 -9
- package/package.json +1 -1
- package/src/flow/SearchFlow.ts +25 -10
|
@@ -15,10 +15,11 @@ declare abstract class SearchFlow {
|
|
|
15
15
|
[key: string]: number;
|
|
16
16
|
} | undefined;
|
|
17
17
|
constructor(params: any);
|
|
18
|
-
buildPopulate(): any;
|
|
19
18
|
buildProjections(): {
|
|
20
19
|
[key: string]: number;
|
|
21
20
|
} | undefined;
|
|
21
|
+
buildPopulate(): any;
|
|
22
|
+
buildPopulateArray(): void;
|
|
22
23
|
buildPath(target: string, nested?: string): any;
|
|
23
24
|
buildOrdenation(): any;
|
|
24
25
|
buildRegex(searchText: string): RegExp;
|
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -105,10 +105,24 @@ var SearchFlow = /** @class */ (function () {
|
|
|
105
105
|
this.buildPopulate();
|
|
106
106
|
this.buildOrdenation();
|
|
107
107
|
}
|
|
108
|
+
SearchFlow.prototype.buildProjections = function () {
|
|
109
|
+
if (!Array.isArray(this.select)) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
var projection = {};
|
|
113
|
+
for (var _i = 0, _a = this.select; _i < _a.length; _i++) {
|
|
114
|
+
var field = _a[_i];
|
|
115
|
+
projection[field] = 1;
|
|
116
|
+
}
|
|
117
|
+
return projection;
|
|
118
|
+
};
|
|
108
119
|
SearchFlow.prototype.buildPopulate = function () {
|
|
109
120
|
if ((0, Utils_1.isEmpty)(this.populate)) {
|
|
110
121
|
return;
|
|
111
122
|
}
|
|
123
|
+
if (Array.isArray(this.populate)) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
112
126
|
var propertiesArray = this.populate.toString().split(',');
|
|
113
127
|
var populates = [];
|
|
114
128
|
for (var _i = 0, propertiesArray_1 = propertiesArray; _i < propertiesArray_1.length; _i++) {
|
|
@@ -119,16 +133,15 @@ var SearchFlow = /** @class */ (function () {
|
|
|
119
133
|
}
|
|
120
134
|
this.populate = populates;
|
|
121
135
|
};
|
|
122
|
-
SearchFlow.prototype.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
projection[field] = 1;
|
|
136
|
+
SearchFlow.prototype.buildPopulateArray = function () {
|
|
137
|
+
var populates = [];
|
|
138
|
+
for (var _i = 0, _a = this.populate; _i < _a.length; _i++) {
|
|
139
|
+
var property = _a[_i];
|
|
140
|
+
var _b = property.split('.'), first = _b[0], rest = _b.slice(1);
|
|
141
|
+
var nested = rest.join('.');
|
|
142
|
+
populates.push(this.buildPath(first, nested));
|
|
130
143
|
}
|
|
131
|
-
|
|
144
|
+
this.populate = populates;
|
|
132
145
|
};
|
|
133
146
|
SearchFlow.prototype.buildPath = function (target, nested) {
|
|
134
147
|
if (nested === void 0) { nested = ""; }
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -31,12 +31,29 @@ abstract class SearchFlow {
|
|
|
31
31
|
this.buildOrdenation()
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
buildProjections() {
|
|
35
|
+
if (!Array.isArray(this.select)) {
|
|
36
|
+
return undefined
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let projection: { [key: string]: number } = {}
|
|
40
|
+
for (var field of this.select) {
|
|
41
|
+
projection[field] = 1
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return projection
|
|
45
|
+
}
|
|
46
|
+
|
|
34
47
|
public buildPopulate(): any {
|
|
35
48
|
if (isEmpty(this.populate)) {
|
|
36
49
|
return
|
|
37
50
|
}
|
|
38
51
|
|
|
39
|
-
|
|
52
|
+
if (Array.isArray(this.populate)) {
|
|
53
|
+
return undefined
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var propertiesArray = (this.populate as string).toString().split(',')
|
|
40
57
|
var populates = [] as any
|
|
41
58
|
for (var property of propertiesArray) {
|
|
42
59
|
let [first, ...rest] = property.split('.')
|
|
@@ -47,17 +64,15 @@ abstract class SearchFlow {
|
|
|
47
64
|
this.populate = populates
|
|
48
65
|
}
|
|
49
66
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
for (var field of this.select) {
|
|
57
|
-
projection[field] = 1
|
|
67
|
+
buildPopulateArray() {
|
|
68
|
+
var populates = [] as any
|
|
69
|
+
for (var property of this.populate) {
|
|
70
|
+
let [first, ...rest] = property.split('.')
|
|
71
|
+
let nested = rest.join('.')
|
|
72
|
+
populates.push(this.buildPath(first, nested))
|
|
58
73
|
}
|
|
59
74
|
|
|
60
|
-
|
|
75
|
+
this.populate = populates
|
|
61
76
|
}
|
|
62
77
|
|
|
63
78
|
public buildPath(target: string, nested: string = "") {
|