c2-mongoose 2.1.91 → 2.1.92

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.
@@ -195,10 +195,11 @@ var SearchFlow = /** @class */ (function () {
195
195
  return __generator(this, function (_c) {
196
196
  switch (_c.label) {
197
197
  case 0:
198
- stagesItems = __spreadArray(__spreadArray([
199
- { $match: this.filters },
198
+ stagesItems = __spreadArray(__spreadArray(__spreadArray(__spreadArray([
199
+ { $match: this.filters }
200
+ ], options.unions, true), [
200
201
  this.projection ? { $project: this.projection } : { $addFields: {} }
201
- ], options.pipelines, true), [
202
+ ], false), options.pipelines, true), [
202
203
  { $sort: this.sort },
203
204
  { $skip: ((this.page - 1) * this.limit) || 0 },
204
205
  { $limit: this.limit },
@@ -207,8 +208,9 @@ var SearchFlow = /** @class */ (function () {
207
208
  {
208
209
  $facet: {
209
210
  items: stagesItems,
210
- paging: [
211
- { $match: this.filters },
211
+ paging: __spreadArray(__spreadArray([
212
+ { $match: this.filters }
213
+ ], options.unions, true), [
212
214
  { $count: "total" },
213
215
  {
214
216
  $addFields: {
@@ -216,7 +218,7 @@ var SearchFlow = /** @class */ (function () {
216
218
  limit: this.limit
217
219
  }
218
220
  }
219
- ]
221
+ ], false)
220
222
  }
221
223
  }
222
224
  ]).session(options === null || options === void 0 ? void 0 : options.session)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.91",
3
+ "version": "2.1.92",
4
4
  "description": "Lib to make any search in database mongoose and use as basic crud",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -120,6 +120,7 @@ abstract class SearchFlow {
120
120
  async searchPageable(model: mongoose.Model<any>, options: SearchOptions) {
121
121
  let stagesItems = [
122
122
  { $match: this.filters },
123
+ ...options.unions,
123
124
  this.projection ? { $project: this.projection } : { $addFields: {} },
124
125
  ...options.pipelines,
125
126
  { $sort: this.sort },
@@ -134,6 +135,7 @@ abstract class SearchFlow {
134
135
  items: stagesItems as any,
135
136
  paging: [
136
137
  { $match: this.filters },
138
+ ...options.unions as any,
137
139
  { $count: "total" },
138
140
  {
139
141
  $addFields:
@@ -16,6 +16,7 @@ declare interface PipelineStage {
16
16
  }
17
17
 
18
18
  declare interface SearchOptions {
19
+ unions: PipelineStage[],
19
20
  pipelines: PipelineStage[],
20
21
  session?: ClientSession
21
22
  }