c2-mongoose 2.1.250 → 2.1.251
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/SearcherFlow.js +24 -24
- package/package.json +1 -1
- package/src/flow/SearcherFlow.ts +29 -31
|
@@ -92,6 +92,7 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
92
92
|
switch (_b.label) {
|
|
93
93
|
case 0:
|
|
94
94
|
stagesItems = [];
|
|
95
|
+
stagesPaging = [];
|
|
95
96
|
if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
|
|
96
97
|
stagesItems.push.apply(stagesItems, options.pipelines);
|
|
97
98
|
}
|
|
@@ -104,35 +105,34 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
104
105
|
stagesItems.push({ $project: BuildSelectSingleFlowItem_1.default.build(this.model, this.select) });
|
|
105
106
|
}
|
|
106
107
|
stagesItems.push({ $sort: this.buildOrdenation() });
|
|
108
|
+
if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
|
|
109
|
+
stagesPaging.push.apply(stagesPaging, options.pipelines);
|
|
110
|
+
}
|
|
111
|
+
if ((0, Utils_1.isNotEmpty)(options.unions)) {
|
|
112
|
+
stagesPaging.push.apply(stagesPaging, options.unions);
|
|
113
|
+
}
|
|
114
|
+
stagesPaging.push({ $match: this.filters });
|
|
115
|
+
stagesPaging.push({ $count: "total" });
|
|
116
|
+
stagesPaging.push({
|
|
117
|
+
$addFields: {
|
|
118
|
+
page: this.pageable === true ? this.page : 1,
|
|
119
|
+
limit: this.pageable === true ? this.limit : '$total',
|
|
120
|
+
totalPages: this.pageable === true ? {
|
|
121
|
+
$cond: {
|
|
122
|
+
if: { $eq: ['$total', 0] },
|
|
123
|
+
then: 0,
|
|
124
|
+
else: { $ceil: { $divide: ['$total', this.limit] } }
|
|
125
|
+
}
|
|
126
|
+
} : 1,
|
|
127
|
+
startIndex: this.pageable === true ? { $subtract: [{ $multiply: [this.page, this.limit] }, this.limit - 1] } : 1,
|
|
128
|
+
endIndex: this.pageable === true ? { $multiply: [this.page, this.limit] } : '$total'
|
|
129
|
+
}
|
|
130
|
+
});
|
|
107
131
|
}
|
|
108
132
|
if (this.pageable === true) {
|
|
109
133
|
stagesItems.push({ $skip: ((this.page - 1) * this.limit) || 0 });
|
|
110
134
|
stagesItems.push({ $limit: this.limit });
|
|
111
135
|
}
|
|
112
|
-
stagesPaging = [];
|
|
113
|
-
if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
|
|
114
|
-
stagesPaging.push.apply(stagesPaging, options.pipelines);
|
|
115
|
-
}
|
|
116
|
-
if ((0, Utils_1.isNotEmpty)(options.unions)) {
|
|
117
|
-
stagesPaging.push.apply(stagesPaging, options.unions);
|
|
118
|
-
}
|
|
119
|
-
stagesPaging.push({ $match: this.filters });
|
|
120
|
-
stagesPaging.push({ $count: "total" });
|
|
121
|
-
stagesPaging.push({
|
|
122
|
-
$addFields: {
|
|
123
|
-
page: this.pageable === true ? this.page : 1,
|
|
124
|
-
limit: this.pageable === true ? this.limit : '$total',
|
|
125
|
-
totalPages: this.pageable === true ? {
|
|
126
|
-
$cond: {
|
|
127
|
-
if: { $eq: ['$total', 0] },
|
|
128
|
-
then: 0,
|
|
129
|
-
else: { $ceil: { $divide: ['$total', this.limit] } }
|
|
130
|
-
}
|
|
131
|
-
} : 1,
|
|
132
|
-
startIndex: this.pageable === true ? { $subtract: [{ $multiply: [this.page, this.limit] }, this.limit - 1] } : 1,
|
|
133
|
-
endIndex: this.pageable === true ? { $multiply: [this.page, this.limit] } : '$total'
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
136
|
stagesMetadata = [];
|
|
137
137
|
if ((0, Utils_1.isNotEmpty)(options.metadata)) {
|
|
138
138
|
stagesMetadata.push.apply(stagesMetadata, options.metadata);
|
package/package.json
CHANGED
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -44,7 +44,7 @@ class SearcherFlow<D> {
|
|
|
44
44
|
async search(options: SearchOptions): Promise<SearchResponse<D>> {
|
|
45
45
|
|
|
46
46
|
let stagesItems: any[] = []
|
|
47
|
-
|
|
47
|
+
let stagesPaging: any[] = []
|
|
48
48
|
if (isNotEmpty(options.pipelines)) {
|
|
49
49
|
stagesItems.push(...options.pipelines)
|
|
50
50
|
}
|
|
@@ -52,13 +52,38 @@ class SearcherFlow<D> {
|
|
|
52
52
|
stagesItems.push(...options.unions)
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
if (isEmpty(options.pipelines)){
|
|
55
|
+
if (isEmpty(options.pipelines)) {
|
|
56
56
|
stagesItems.push({ $match: this.filters })
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
if (isNotEmpty(this.select)) {
|
|
59
59
|
stagesItems.push({ $project: BuildSelectSingleFlowItem.build(this.model, this.select) })
|
|
60
60
|
}
|
|
61
61
|
stagesItems.push({ $sort: this.buildOrdenation() })
|
|
62
|
+
|
|
63
|
+
if (isNotEmpty(options.pipelines)) {
|
|
64
|
+
stagesPaging.push(...options.pipelines)
|
|
65
|
+
}
|
|
66
|
+
if (isNotEmpty(options.unions)) {
|
|
67
|
+
stagesPaging.push(...options.unions)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
stagesPaging.push({ $match: this.filters })
|
|
71
|
+
stagesPaging.push({ $count: "total" })
|
|
72
|
+
stagesPaging.push({
|
|
73
|
+
$addFields: {
|
|
74
|
+
page: this.pageable === true ? this.page : 1,
|
|
75
|
+
limit: this.pageable === true ? this.limit : '$total',
|
|
76
|
+
totalPages: this.pageable === true ? {
|
|
77
|
+
$cond: {
|
|
78
|
+
if: { $eq: ['$total', 0] },
|
|
79
|
+
then: 0,
|
|
80
|
+
else: { $ceil: { $divide: ['$total', this.limit] } }
|
|
81
|
+
}
|
|
82
|
+
} : 1,
|
|
83
|
+
startIndex: this.pageable === true ? { $subtract: [{ $multiply: [this.page, this.limit] }, this.limit - 1] } : 1,
|
|
84
|
+
endIndex: this.pageable === true ? { $multiply: [this.page, this.limit] } : '$total'
|
|
85
|
+
}
|
|
86
|
+
})
|
|
62
87
|
}
|
|
63
88
|
|
|
64
89
|
if (this.pageable === true) {
|
|
@@ -66,33 +91,6 @@ class SearcherFlow<D> {
|
|
|
66
91
|
stagesItems.push({ $limit: this.limit })
|
|
67
92
|
}
|
|
68
93
|
|
|
69
|
-
|
|
70
|
-
let stagesPaging: any[] = []
|
|
71
|
-
if (isNotEmpty(options.pipelines)) {
|
|
72
|
-
stagesPaging.push(...options.pipelines)
|
|
73
|
-
}
|
|
74
|
-
if (isNotEmpty(options.unions)) {
|
|
75
|
-
stagesPaging.push(...options.unions)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
stagesPaging.push({ $match: this.filters })
|
|
79
|
-
stagesPaging.push({ $count: "total" })
|
|
80
|
-
stagesPaging.push({
|
|
81
|
-
$addFields: {
|
|
82
|
-
page: this.pageable === true ? this.page : 1,
|
|
83
|
-
limit: this.pageable === true ? this.limit : '$total',
|
|
84
|
-
totalPages: this.pageable === true ? {
|
|
85
|
-
$cond: {
|
|
86
|
-
if: { $eq: ['$total', 0] },
|
|
87
|
-
then: 0,
|
|
88
|
-
else: { $ceil: { $divide: ['$total', this.limit] } }
|
|
89
|
-
}
|
|
90
|
-
} : 1,
|
|
91
|
-
startIndex: this.pageable === true ? { $subtract: [{ $multiply: [this.page, this.limit] }, this.limit - 1] } : 1,
|
|
92
|
-
endIndex: this.pageable === true ? { $multiply: [this.page, this.limit] } : '$total'
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
|
|
96
94
|
let stagesMetadata: any[] = []
|
|
97
95
|
if (isNotEmpty(options.metadata)) {
|
|
98
96
|
stagesMetadata.push(...options.metadata)
|
|
@@ -154,7 +152,7 @@ class SearcherFlow<D> {
|
|
|
154
152
|
};
|
|
155
153
|
}
|
|
156
154
|
|
|
157
|
-
extractFieldsOfType(schema: Schema, typing = 'String', parent = ''): string[]{
|
|
155
|
+
extractFieldsOfType(schema: Schema, typing = 'String', parent = ''): string[] {
|
|
158
156
|
let fieldsTyped: string[] = []
|
|
159
157
|
Object.keys(schema.paths).forEach((field: string) => {
|
|
160
158
|
if (schema.paths[field].instance === typing) {
|