c2-mongoose 2.1.308 → 2.1.310
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.d.ts +1 -38
- package/dist/flow/SearcherFlow.js +24 -21
- package/package.json +1 -1
- package/src/flow/SearcherFlow.ts +24 -21
|
@@ -38,43 +38,6 @@ declare class SearcherFlow<D> {
|
|
|
38
38
|
buildOrdenation(): any;
|
|
39
39
|
buildRegex(searchText: string): RegExp;
|
|
40
40
|
buildGrouping(fieldsToGroup: string[], sumFields: string[], countFields: string[]): void;
|
|
41
|
-
|
|
42
|
-
$addFields: {
|
|
43
|
-
page: number;
|
|
44
|
-
limit: number;
|
|
45
|
-
total: string;
|
|
46
|
-
totalPages: {
|
|
47
|
-
$cond: {
|
|
48
|
-
if: {
|
|
49
|
-
$eq: (string | number)[];
|
|
50
|
-
};
|
|
51
|
-
then: number;
|
|
52
|
-
else: {
|
|
53
|
-
$ceil: {
|
|
54
|
-
$divide: (string | number)[];
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
startIndex: {
|
|
60
|
-
$subtract: (number | {
|
|
61
|
-
$multiply: number[];
|
|
62
|
-
})[];
|
|
63
|
-
};
|
|
64
|
-
endIndex: {
|
|
65
|
-
$cond: {
|
|
66
|
-
if: {
|
|
67
|
-
$gt: (string | {
|
|
68
|
-
$multiply: number[];
|
|
69
|
-
})[];
|
|
70
|
-
};
|
|
71
|
-
then: string;
|
|
72
|
-
else: {
|
|
73
|
-
$multiply: number[];
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
};
|
|
41
|
+
buildPaginationData(): any[];
|
|
79
42
|
}
|
|
80
43
|
export default SearcherFlow;
|
|
@@ -115,7 +115,7 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
115
115
|
}
|
|
116
116
|
if ((0, Utils_1.isEmpty)(options.paging) && this.pageable) {
|
|
117
117
|
stagesPaging.push({ $match: this.filters });
|
|
118
|
-
stagesPaging
|
|
118
|
+
stagesPaging = __spreadArray(__spreadArray([], stagesItems, true), this.buildPaginationData(), true);
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
121
121
|
stagesPaging = __spreadArray(__spreadArray([], stagesPaging, true), options.paging, true);
|
|
@@ -451,29 +451,32 @@ var SearcherFlow = /** @class */ (function () {
|
|
|
451
451
|
groupsClauses.push(groupClause);
|
|
452
452
|
});
|
|
453
453
|
};
|
|
454
|
-
SearcherFlow.prototype.
|
|
455
|
-
return
|
|
456
|
-
$
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
$
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
454
|
+
SearcherFlow.prototype.buildPaginationData = function () {
|
|
455
|
+
return [
|
|
456
|
+
{ $count: "total" },
|
|
457
|
+
{
|
|
458
|
+
$addFields: {
|
|
459
|
+
page: this.page,
|
|
460
|
+
limit: this.limit,
|
|
461
|
+
total: "$total",
|
|
462
|
+
totalPages: {
|
|
463
|
+
$cond: {
|
|
464
|
+
if: { $eq: ['$total', 0] },
|
|
465
|
+
then: 0,
|
|
466
|
+
else: { $ceil: { $divide: ['$total', this.limit] } }
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
startIndex: { $subtract: [{ $multiply: [this.page, this.limit] }, this.limit - 1] },
|
|
470
|
+
endIndex: {
|
|
471
|
+
$cond: {
|
|
472
|
+
if: { $gt: [{ $multiply: [this.page, this.limit] }, "$total"] },
|
|
473
|
+
then: "$total",
|
|
474
|
+
else: { $multiply: [this.page, this.limit] }
|
|
475
|
+
}
|
|
473
476
|
}
|
|
474
477
|
}
|
|
475
478
|
}
|
|
476
|
-
|
|
479
|
+
];
|
|
477
480
|
};
|
|
478
481
|
return SearcherFlow;
|
|
479
482
|
}());
|
package/package.json
CHANGED
package/src/flow/SearcherFlow.ts
CHANGED
|
@@ -79,7 +79,7 @@ class SearcherFlow<D> {
|
|
|
79
79
|
|
|
80
80
|
if (isEmpty(options.paging) && this.pageable) {
|
|
81
81
|
stagesPaging.push({ $match: this.filters })
|
|
82
|
-
stagesPaging
|
|
82
|
+
stagesPaging = [...stagesItems, ...this.buildPaginationData()]
|
|
83
83
|
} else {
|
|
84
84
|
stagesPaging = [...stagesPaging, ...options.paging]
|
|
85
85
|
}
|
|
@@ -445,29 +445,32 @@ class SearcherFlow<D> {
|
|
|
445
445
|
})
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
-
|
|
449
|
-
return
|
|
450
|
-
$
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
$
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
448
|
+
buildPaginationData(): any[] {
|
|
449
|
+
return [
|
|
450
|
+
{ $count: "total" },
|
|
451
|
+
{
|
|
452
|
+
$addFields: {
|
|
453
|
+
page: this.page,
|
|
454
|
+
limit: this.limit,
|
|
455
|
+
total: "$total",
|
|
456
|
+
totalPages: {
|
|
457
|
+
$cond: {
|
|
458
|
+
if: { $eq: ['$total', 0] },
|
|
459
|
+
then: 0,
|
|
460
|
+
else: { $ceil: { $divide: ['$total', this.limit] } }
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
startIndex: { $subtract: [{ $multiply: [this.page, this.limit] }, this.limit - 1] },
|
|
464
|
+
endIndex: {
|
|
465
|
+
$cond: {
|
|
466
|
+
if: { $gt: [{ $multiply: [this.page, this.limit] }, "$total"] },
|
|
467
|
+
then: "$total",
|
|
468
|
+
else: { $multiply: [this.page, this.limit] }
|
|
469
|
+
}
|
|
467
470
|
}
|
|
468
471
|
}
|
|
469
472
|
}
|
|
470
|
-
|
|
473
|
+
]
|
|
471
474
|
}
|
|
472
475
|
}
|
|
473
476
|
|