c2-mongoose 2.1.91 → 2.1.93

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.
@@ -197,6 +197,7 @@ var SearchFlow = /** @class */ (function () {
197
197
  case 0:
198
198
  stagesItems = __spreadArray(__spreadArray([
199
199
  { $match: this.filters },
200
+ (0, Utils_1.isNotEmpty)(options.unions) ? __spreadArray([], options.unions, true) : undefined,
200
201
  this.projection ? { $project: this.projection } : { $addFields: {} }
201
202
  ], options.pipelines, true), [
202
203
  { $sort: this.sort },
@@ -209,6 +210,7 @@ var SearchFlow = /** @class */ (function () {
209
210
  items: stagesItems,
210
211
  paging: [
211
212
  { $match: this.filters },
213
+ (0, Utils_1.isNotEmpty)(options.unions) ? __spreadArray([], options.unions, true) : undefined,
212
214
  { $count: "total" },
213
215
  {
214
216
  $addFields: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.91",
3
+ "version": "2.1.93",
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
+ isNotEmpty(options.unions) ? [...options.unions] : undefined,
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
+ isNotEmpty(options.unions) ? [...options.unions] as any : undefined,
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
  }