c2-mongoose 2.1.220 → 2.1.222
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.
|
@@ -63,7 +63,7 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
63
63
|
this.page = 1;
|
|
64
64
|
this.limit = 50;
|
|
65
65
|
this.pageable = true;
|
|
66
|
-
this.
|
|
66
|
+
this.select = [""];
|
|
67
67
|
this.populate = [""];
|
|
68
68
|
this.filters = undefined;
|
|
69
69
|
this.model = repository;
|
|
@@ -95,8 +95,8 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
95
95
|
stagesItems.push.apply(stagesItems, options.unions);
|
|
96
96
|
}
|
|
97
97
|
stagesItems.push({ $match: this.filters });
|
|
98
|
-
if ((0, Utils_1.isNotEmpty)(this.
|
|
99
|
-
stagesItems.push({ $project: BuildSelectSingleFlowItem_1.default.build(model, this.
|
|
98
|
+
if ((0, Utils_1.isNotEmpty)(this.select)) {
|
|
99
|
+
stagesItems.push({ $project: BuildSelectSingleFlowItem_1.default.build(model, this.select) });
|
|
100
100
|
}
|
|
101
101
|
// stagesItems.push({ $sort: this.sort })
|
|
102
102
|
if (this.pageable === true) {
|
|
@@ -154,7 +154,7 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
154
154
|
result = _b.sent();
|
|
155
155
|
if (!(0, Utils_1.isNotEmpty)(this.populate)) return [3 /*break*/, 3];
|
|
156
156
|
_a = result[0];
|
|
157
|
-
return [4 /*yield*/, model.populate(result[0].items, BuildPopulateSingleFlowItem_1.default.buildPopulate(model, this.populate, this.
|
|
157
|
+
return [4 /*yield*/, model.populate(result[0].items, BuildPopulateSingleFlowItem_1.default.buildPopulate(model, this.populate, this.select))];
|
|
158
158
|
case 2:
|
|
159
159
|
_a.items = _b.sent();
|
|
160
160
|
_b.label = 3;
|
|
@@ -202,7 +202,7 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
202
202
|
'page',
|
|
203
203
|
'limit',
|
|
204
204
|
'model',
|
|
205
|
-
'
|
|
205
|
+
'select',
|
|
206
206
|
'searchText',
|
|
207
207
|
'sort',
|
|
208
208
|
'isPageable',
|
|
@@ -27,7 +27,7 @@ var BuildPopulateSingleFlowItem = /** @class */ (function () {
|
|
|
27
27
|
var populateLocal = this_1.buildPath(first, nested);
|
|
28
28
|
if (Array.isArray(selectsStr)) {
|
|
29
29
|
var selects = selectsStr.filter(function (sel) { return sel.startsWith("".concat(first, ".")); });
|
|
30
|
-
var select = selects.map(function (sel) { return sel.split(".")[1]; }).join(" ");
|
|
30
|
+
var select = Array.from(new Set(selects)).map(function (sel) { return sel.split(".")[1]; }).join(" ").trim();
|
|
31
31
|
if ((0, Utils_1.isNotEmpty)(select)) {
|
|
32
32
|
populateLocal.select = select;
|
|
33
33
|
}
|
package/package.json
CHANGED
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -24,7 +24,7 @@ class SearcherFlow<D> {
|
|
|
24
24
|
private limit: number = 50
|
|
25
25
|
private pageable: boolean = true
|
|
26
26
|
|
|
27
|
-
private
|
|
27
|
+
private select: string[] = [""]
|
|
28
28
|
private populate: string[] = [""]
|
|
29
29
|
private filters: any = undefined
|
|
30
30
|
|
|
@@ -61,8 +61,8 @@ class SearcherFlow<D> {
|
|
|
61
61
|
|
|
62
62
|
stagesItems.push({ $match: this.filters })
|
|
63
63
|
|
|
64
|
-
if (isNotEmpty(this.
|
|
65
|
-
stagesItems.push({ $project: BuildSelectSingleFlowItem.build(model, this.
|
|
64
|
+
if (isNotEmpty(this.select)) {
|
|
65
|
+
stagesItems.push({ $project: BuildSelectSingleFlowItem.build(model, this.select) })
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// stagesItems.push({ $sort: this.sort })
|
|
@@ -127,7 +127,7 @@ class SearcherFlow<D> {
|
|
|
127
127
|
|
|
128
128
|
|
|
129
129
|
if (isNotEmpty(this.populate)) {
|
|
130
|
-
result[0].items = await model.populate(result[0].items, BuildPopulateSingleFlowItem.buildPopulate(model, this.populate, this.
|
|
130
|
+
result[0].items = await model.populate(result[0].items, BuildPopulateSingleFlowItem.buildPopulate(model, this.populate, this.select))
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
let resultAux = this.transformObject(result[0])
|
|
@@ -176,7 +176,7 @@ class SearcherFlow<D> {
|
|
|
176
176
|
'page',
|
|
177
177
|
'limit',
|
|
178
178
|
'model',
|
|
179
|
-
'
|
|
179
|
+
'select',
|
|
180
180
|
'searchText',
|
|
181
181
|
'sort',
|
|
182
182
|
'isPageable',
|
|
@@ -18,7 +18,7 @@ class BuildPopulateSingleFlowItem {
|
|
|
18
18
|
|
|
19
19
|
if (Array.isArray(selectsStr)) {
|
|
20
20
|
let selects = (selectsStr as []).filter((sel: string) => sel.startsWith(`${first}.`))
|
|
21
|
-
let select = selects.map((sel: string) => sel.split(".")[1]).join(" ")
|
|
21
|
+
let select = Array.from(new Set(selects)).map((sel: string) => sel.split(".")[1]).join(" ").trim()
|
|
22
22
|
if (isNotEmpty(select)) {
|
|
23
23
|
populateLocal.select = select
|
|
24
24
|
}
|