c2-mongoose 2.1.203 → 2.1.204
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 -1
- package/package.json +1 -1
- package/src/flow/SearchFlow.ts +16 -1
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -256,7 +256,21 @@ var SearchFlow = /** @class */ (function () {
|
|
|
256
256
|
}
|
|
257
257
|
stagesPaging.push({ $match: this.filters });
|
|
258
258
|
stagesPaging.push({ $count: "total" });
|
|
259
|
-
stagesPaging.push({
|
|
259
|
+
stagesPaging.push({
|
|
260
|
+
$addFields: {
|
|
261
|
+
page: this.page || 1,
|
|
262
|
+
limit: this.limit,
|
|
263
|
+
totalPages: {
|
|
264
|
+
$cond: {
|
|
265
|
+
if: { $eq: ['$total', 0] },
|
|
266
|
+
then: 0,
|
|
267
|
+
else: { $ceil: { $divide: ['$total', this.limit] } }
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
startIndex: { $subtract: [{ $multiply: [this.page, this.limit] }, this.limit] },
|
|
271
|
+
endIndex: { $multiply: [this.page, this.limit] }
|
|
272
|
+
}
|
|
273
|
+
});
|
|
260
274
|
stagesMetadata = [];
|
|
261
275
|
if ((0, Utils_1.isNotEmpty)(options.metadata)) {
|
|
262
276
|
stagesMetadata.push.apply(stagesMetadata, options.metadata);
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -243,7 +243,22 @@ abstract class SearchFlow {
|
|
|
243
243
|
}
|
|
244
244
|
stagesPaging.push({ $match: this.filters })
|
|
245
245
|
stagesPaging.push({ $count: "total" })
|
|
246
|
-
stagesPaging.push(
|
|
246
|
+
stagesPaging.push(
|
|
247
|
+
{
|
|
248
|
+
$addFields: {
|
|
249
|
+
page: this.page || 1,
|
|
250
|
+
limit: this.limit,
|
|
251
|
+
totalPages: {
|
|
252
|
+
$cond: {
|
|
253
|
+
if: { $eq: ['$total', 0] },
|
|
254
|
+
then: 0,
|
|
255
|
+
else: { $ceil: { $divide: ['$total', this.limit] } }
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
startIndex: { $subtract: [ { $multiply: [this.page, this.limit] }, this.limit ] },
|
|
259
|
+
endIndex: { $multiply: [this.page, this.limit] }
|
|
260
|
+
}
|
|
261
|
+
})
|
|
247
262
|
|
|
248
263
|
let stagesMetadata: any[] = []
|
|
249
264
|
if (isNotEmpty(options.metadata)) {
|