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