c2-mongoose 2.1.46 → 2.1.47
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 +32 -22
- package/package.json +1 -1
- package/src/flow/SearchFlow.ts +9 -7
package/dist/flow/SearchFlow.js
CHANGED
|
@@ -46,6 +46,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
49
58
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
59
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
60
|
};
|
|
@@ -138,32 +147,33 @@ var SearchFlow = /** @class */ (function () {
|
|
|
138
147
|
};
|
|
139
148
|
SearchFlow.prototype.searchPageable = function (model, pipeline) {
|
|
140
149
|
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
-
var result;
|
|
150
|
+
var stagesItems, result;
|
|
142
151
|
return __generator(this, function (_a) {
|
|
143
152
|
switch (_a.label) {
|
|
144
|
-
case 0:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
153
|
+
case 0:
|
|
154
|
+
stagesItems = __spreadArray([
|
|
155
|
+
{ $match: this.filters },
|
|
156
|
+
{ $sort: this.sort },
|
|
157
|
+
{ $skip: (this.page - 1) * this.limit },
|
|
158
|
+
{ $limit: this.limit }
|
|
159
|
+
], pipeline, true);
|
|
160
|
+
return [4 /*yield*/, model.aggregate([
|
|
161
|
+
{
|
|
162
|
+
$facet: {
|
|
163
|
+
items: stagesItems,
|
|
164
|
+
paging: [
|
|
165
|
+
{ $match: this.filters },
|
|
166
|
+
{ $count: "total" },
|
|
167
|
+
{
|
|
168
|
+
$addFields: {
|
|
169
|
+
page: this.page,
|
|
170
|
+
limit: this.limit
|
|
171
|
+
}
|
|
161
172
|
}
|
|
162
|
-
|
|
163
|
-
|
|
173
|
+
]
|
|
174
|
+
}
|
|
164
175
|
}
|
|
165
|
-
|
|
166
|
-
])];
|
|
176
|
+
])];
|
|
167
177
|
case 1:
|
|
168
178
|
result = _a.sent();
|
|
169
179
|
return [2 /*return*/, result[0]];
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -75,17 +75,19 @@ abstract class SearchFlow {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
async searchPageable(model: mongoose.Model<any>, pipeline: any) {
|
|
78
|
+
let stagesItems = [
|
|
79
|
+
{ $match: this.filters },
|
|
80
|
+
{ $sort: this.sort },
|
|
81
|
+
{ $skip: (this.page - 1) * this.limit },
|
|
82
|
+
{ $limit: this.limit },
|
|
83
|
+
...pipeline
|
|
84
|
+
]
|
|
85
|
+
|
|
78
86
|
const result = await model.aggregate(
|
|
79
87
|
[
|
|
80
88
|
{
|
|
81
89
|
$facet: {
|
|
82
|
-
items:
|
|
83
|
-
{ $match: this.filters },
|
|
84
|
-
{ $sort: this.sort },
|
|
85
|
-
{ $skip: (this.page - 1) * this.limit },
|
|
86
|
-
{ $limit: this.limit },
|
|
87
|
-
pipeline
|
|
88
|
-
],
|
|
90
|
+
items: stagesItems,
|
|
89
91
|
paging: [
|
|
90
92
|
{ $match: this.filters },
|
|
91
93
|
{ $count: "total" },
|