c2-mongoose 2.1.102 → 2.1.103
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
CHANGED
|
@@ -187,7 +187,7 @@ var SearchFlow = /** @class */ (function () {
|
|
|
187
187
|
SearchFlow.prototype.searchPageable = function (model, options) {
|
|
188
188
|
var _a;
|
|
189
189
|
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
-
var stagesItems, stagesPaging, result, items, _i, _b, populate;
|
|
190
|
+
var stagesItems, stagesPaging, stagesMetadata, result, items, _i, _b, populate;
|
|
191
191
|
return __generator(this, function (_c) {
|
|
192
192
|
switch (_c.label) {
|
|
193
193
|
case 0:
|
|
@@ -210,11 +210,16 @@ var SearchFlow = /** @class */ (function () {
|
|
|
210
210
|
}
|
|
211
211
|
stagesPaging.push({ $count: "total" });
|
|
212
212
|
stagesPaging.push({ $addFields: { page: this.page || 1, limit: this.limit } });
|
|
213
|
+
stagesMetadata = [];
|
|
214
|
+
if ((0, Utils_1.isNotEmpty)(options.metadata)) {
|
|
215
|
+
stagesMetadata.push.apply(stagesMetadata, options.metadata);
|
|
216
|
+
}
|
|
213
217
|
return [4 /*yield*/, model.aggregate([
|
|
214
218
|
{
|
|
215
219
|
$facet: {
|
|
216
220
|
items: stagesItems,
|
|
217
|
-
paging: stagesPaging
|
|
221
|
+
paging: stagesPaging,
|
|
222
|
+
metadata: stagesMetadata
|
|
218
223
|
}
|
|
219
224
|
}
|
|
220
225
|
]).session(options === null || options === void 0 ? void 0 : options.session)];
|
package/package.json
CHANGED
package/src/flow/SearchFlow.ts
CHANGED
|
@@ -123,15 +123,6 @@ abstract class SearchFlow {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
async searchPageable(model: mongoose.Model<any>, options: SearchOptions) {
|
|
126
|
-
// let stagesItems = [
|
|
127
|
-
// { $match: this.filters },
|
|
128
|
-
// isNotEmpty(options.unions) ? options.unions : undefined,
|
|
129
|
-
// this.projection ? { $project: this.projection } : { $addFields: {} },
|
|
130
|
-
// ...options.pipelines,
|
|
131
|
-
// { $sort: this.sort },
|
|
132
|
-
// { $skip: ((this.page - 1) * this.limit) || 0 },
|
|
133
|
-
// { $limit: this.limit },
|
|
134
|
-
// ]
|
|
135
126
|
|
|
136
127
|
let stagesItems: any[] = [{ $match: this.filters }]
|
|
137
128
|
|
|
@@ -159,13 +150,18 @@ abstract class SearchFlow {
|
|
|
159
150
|
stagesPaging.push({ $count: "total" })
|
|
160
151
|
stagesPaging.push({ $addFields: { page: this.page || 1, limit: this.limit } })
|
|
161
152
|
|
|
153
|
+
let stagesMetadata: any[] = []
|
|
154
|
+
if (isNotEmpty(options.metadata)) {
|
|
155
|
+
stagesMetadata.push(...options.metadata)
|
|
156
|
+
}
|
|
162
157
|
|
|
163
158
|
const result = await model.aggregate(
|
|
164
159
|
[
|
|
165
160
|
{
|
|
166
161
|
$facet: {
|
|
167
162
|
items: stagesItems,
|
|
168
|
-
paging: stagesPaging
|
|
163
|
+
paging: stagesPaging,
|
|
164
|
+
metadata: stagesMetadata
|
|
169
165
|
}
|
|
170
166
|
}
|
|
171
167
|
]
|