c2-mongoose 2.1.128 → 2.1.130
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 -6
- package/package.json +1 -1
- package/src/flow/SearchFlow.ts +14 -10
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,23 +219,28 @@ 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
|
}
|
|
229
|
-
if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
|
|
230
|
-
stagesItems.push.apply(stagesItems, options.pipelines);
|
|
231
|
-
}
|
|
232
233
|
stagesItems.push({ $sort: this.sort });
|
|
233
234
|
stagesItems.push({ $skip: ((this.page - 1) * this.limit) || 0 });
|
|
234
235
|
stagesItems.push({ $limit: this.limit });
|
|
235
|
-
stagesPaging = [
|
|
236
|
+
stagesPaging = [];
|
|
237
|
+
if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
|
|
238
|
+
stagesPaging.push.apply(stagesPaging, options.pipelines);
|
|
239
|
+
}
|
|
236
240
|
if ((0, Utils_1.isNotEmpty)(options.unions)) {
|
|
237
241
|
stagesPaging.push.apply(stagesPaging, options.unions);
|
|
238
242
|
}
|
|
243
|
+
stagesPaging.push({ $match: this.filters });
|
|
239
244
|
stagesPaging.push({ $count: "total" });
|
|
240
245
|
stagesPaging.push({ $addFields: { page: this.page || 1, limit: this.limit } });
|
|
241
246
|
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,29 +178,35 @@ 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
|
}
|
|
192
195
|
|
|
193
|
-
if (isNotEmpty(options.pipelines)) {
|
|
194
|
-
stagesItems.push(...options.pipelines)
|
|
195
|
-
}
|
|
196
|
-
|
|
197
196
|
stagesItems.push({ $sort: this.sort })
|
|
198
197
|
stagesItems.push({ $skip: ((this.page - 1) * this.limit) || 0 })
|
|
199
198
|
stagesItems.push({ $limit: this.limit })
|
|
200
199
|
|
|
201
200
|
|
|
202
|
-
let stagesPaging: any[] = [
|
|
201
|
+
let stagesPaging: any[] = []
|
|
202
|
+
|
|
203
|
+
if (isNotEmpty(options.pipelines)) {
|
|
204
|
+
stagesPaging.push(...options.pipelines)
|
|
205
|
+
}
|
|
203
206
|
if (isNotEmpty(options.unions)) {
|
|
204
207
|
stagesPaging.push(...options.unions)
|
|
205
208
|
}
|
|
209
|
+
stagesPaging.push({ $match: this.filters })
|
|
206
210
|
stagesPaging.push({ $count: "total" })
|
|
207
211
|
stagesPaging.push({ $addFields: { page: this.page || 1, limit: this.limit } })
|
|
208
212
|
|