c2-mongoose 2.1.127 → 2.1.129
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.js +15 -6
- package/package.json +1 -1
- package/src/flow/SearchFlow.ts +18 -6
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -161,16 +161,17 @@ var SearchFlow = /** @class */ (function () {
|
|
|
161
161
|
return __generator(this, function (_d) {
|
|
162
162
|
switch (_d.label) {
|
|
163
163
|
case 0:
|
|
164
|
-
stagesItems = [
|
|
164
|
+
stagesItems = [];
|
|
165
|
+
if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
|
|
166
|
+
stagesItems.push.apply(stagesItems, options.pipelines);
|
|
167
|
+
}
|
|
165
168
|
if ((0, Utils_1.isNotEmpty)(options.unions)) {
|
|
166
169
|
stagesItems.push.apply(stagesItems, options.unions);
|
|
167
170
|
}
|
|
171
|
+
stagesItems.push({ $match: this.filters });
|
|
168
172
|
if ((0, Utils_1.isNotEmpty)(this.projection)) {
|
|
169
173
|
stagesItems.push({ $project: this.projection });
|
|
170
174
|
}
|
|
171
|
-
if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
|
|
172
|
-
stagesItems.push.apply(stagesItems, options.pipelines);
|
|
173
|
-
}
|
|
174
175
|
stagesItems.push({ $sort: this.sort });
|
|
175
176
|
stagesItems.push({ $limit: (_a = this.limit) !== null && _a !== void 0 ? _a : 50 });
|
|
176
177
|
stagesMetadata = [];
|
|
@@ -218,10 +219,14 @@ var SearchFlow = /** @class */ (function () {
|
|
|
218
219
|
return __generator(this, function (_c) {
|
|
219
220
|
switch (_c.label) {
|
|
220
221
|
case 0:
|
|
221
|
-
stagesItems = [
|
|
222
|
+
stagesItems = [];
|
|
223
|
+
if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
|
|
224
|
+
stagesItems.push.apply(stagesItems, options.pipelines);
|
|
225
|
+
}
|
|
222
226
|
if ((0, Utils_1.isNotEmpty)(options.unions)) {
|
|
223
227
|
stagesItems.push.apply(stagesItems, options.unions);
|
|
224
228
|
}
|
|
229
|
+
stagesItems.push({ $match: this.filters });
|
|
225
230
|
if ((0, Utils_1.isNotEmpty)(this.projection)) {
|
|
226
231
|
stagesItems.push({ $project: this.projection });
|
|
227
232
|
}
|
|
@@ -231,10 +236,14 @@ var SearchFlow = /** @class */ (function () {
|
|
|
231
236
|
stagesItems.push({ $sort: this.sort });
|
|
232
237
|
stagesItems.push({ $skip: ((this.page - 1) * this.limit) || 0 });
|
|
233
238
|
stagesItems.push({ $limit: this.limit });
|
|
234
|
-
stagesPaging = [
|
|
239
|
+
stagesPaging = [];
|
|
240
|
+
if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
|
|
241
|
+
stagesPaging.push.apply(stagesPaging, options.pipelines);
|
|
242
|
+
}
|
|
235
243
|
if ((0, Utils_1.isNotEmpty)(options.unions)) {
|
|
236
244
|
stagesPaging.push.apply(stagesPaging, options.unions);
|
|
237
245
|
}
|
|
246
|
+
stagesPaging.push({ $match: this.filters });
|
|
238
247
|
stagesPaging.push({ $count: "total" });
|
|
239
248
|
stagesPaging.push({ $addFields: { page: this.page || 1, limit: this.limit } });
|
|
240
249
|
stagesMetadata = [];
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -123,19 +123,21 @@ abstract class SearchFlow {
|
|
|
123
123
|
|
|
124
124
|
async searchNoPageable(model: mongoose.Model<any>, options: SearchOptions) {
|
|
125
125
|
|
|
126
|
-
let stagesItems: any[] = [
|
|
126
|
+
let stagesItems: any[] = []
|
|
127
127
|
|
|
128
|
+
if (isNotEmpty(options.pipelines)) {
|
|
129
|
+
stagesItems.push(...options.pipelines)
|
|
130
|
+
}
|
|
128
131
|
if (isNotEmpty(options.unions)) {
|
|
129
132
|
stagesItems.push(...options.unions)
|
|
130
133
|
}
|
|
131
134
|
|
|
135
|
+
stagesItems.push({ $match: this.filters })
|
|
136
|
+
|
|
132
137
|
if (isNotEmpty(this.projection)) {
|
|
133
138
|
stagesItems.push({ $project: this.projection })
|
|
134
139
|
}
|
|
135
140
|
|
|
136
|
-
if (isNotEmpty(options.pipelines)) {
|
|
137
|
-
stagesItems.push(...options.pipelines)
|
|
138
|
-
}
|
|
139
141
|
|
|
140
142
|
stagesItems.push({ $sort: this.sort })
|
|
141
143
|
stagesItems.push({ $limit: this.limit ?? 50 })
|
|
@@ -176,12 +178,17 @@ abstract class SearchFlow {
|
|
|
176
178
|
|
|
177
179
|
async searchPageable(model: mongoose.Model<any>, options: SearchOptions) {
|
|
178
180
|
|
|
179
|
-
let stagesItems: any[] = [
|
|
181
|
+
let stagesItems: any[] = []
|
|
180
182
|
|
|
183
|
+
if (isNotEmpty(options.pipelines)) {
|
|
184
|
+
stagesItems.push(...options.pipelines)
|
|
185
|
+
}
|
|
181
186
|
if (isNotEmpty(options.unions)) {
|
|
182
187
|
stagesItems.push(...options.unions)
|
|
183
188
|
}
|
|
184
189
|
|
|
190
|
+
stagesItems.push({ $match: this.filters })
|
|
191
|
+
|
|
185
192
|
if (isNotEmpty(this.projection)) {
|
|
186
193
|
stagesItems.push({ $project: this.projection })
|
|
187
194
|
}
|
|
@@ -195,10 +202,15 @@ abstract class SearchFlow {
|
|
|
195
202
|
stagesItems.push({ $limit: this.limit })
|
|
196
203
|
|
|
197
204
|
|
|
198
|
-
let stagesPaging: any[] = [
|
|
205
|
+
let stagesPaging: any[] = []
|
|
206
|
+
|
|
207
|
+
if (isNotEmpty(options.pipelines)) {
|
|
208
|
+
stagesPaging.push(...options.pipelines)
|
|
209
|
+
}
|
|
199
210
|
if (isNotEmpty(options.unions)) {
|
|
200
211
|
stagesPaging.push(...options.unions)
|
|
201
212
|
}
|
|
213
|
+
stagesPaging.push({ $match: this.filters })
|
|
202
214
|
stagesPaging.push({ $count: "total" })
|
|
203
215
|
stagesPaging.push({ $addFields: { page: this.page || 1, limit: this.limit } })
|
|
204
216
|
|