c2-mongoose 2.1.402 → 2.1.404

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.
@@ -1,7 +1,8 @@
1
1
  import mongoose from "mongoose";
2
2
  import { IForeingData } from "./item/OneToManyFlowItem";
3
+ import { IParams } from "./SearcherV3Flow";
3
4
  declare class GetOneByFilterV3Flow {
4
- exec(params: any, model: mongoose.Model<any>, oneToMany?: IForeingData[]): Promise<any>;
5
+ exec(params: IParams, model: mongoose.Model<any>, oneToMany?: IForeingData[]): Promise<any>;
5
6
  }
6
7
  declare const _default: GetOneByFilterV3Flow;
7
8
  export default _default;
@@ -56,16 +56,23 @@ var GetOneByFilterV3Flow = /** @class */ (function () {
56
56
  function GetOneByFilterV3Flow() {
57
57
  }
58
58
  GetOneByFilterV3Flow.prototype.exec = function (params, model, oneToMany) {
59
+ var _a, _b;
59
60
  if (oneToMany === void 0) { oneToMany = []; }
60
61
  return __awaiter(this, void 0, void 0, function () {
61
62
  var pipeline, result;
62
- return __generator(this, function (_a) {
63
- switch (_a.label) {
63
+ return __generator(this, function (_c) {
64
+ switch (_c.label) {
64
65
  case 0:
65
66
  pipeline = [];
67
+ if ((_a = params.preSteps) === null || _a === void 0 ? void 0 : _a.length) {
68
+ pipeline = __spreadArray(__spreadArray([], pipeline, true), params.preSteps, true);
69
+ }
66
70
  pipeline = __spreadArray(__spreadArray([], pipeline, true), PopulateFlowItem_1.default.execute(params.populate, model), true);
67
71
  pipeline = __spreadArray(__spreadArray([], pipeline, true), OneToManyFlowItem_1.default.execute(oneToMany, params.populate), true);
68
72
  pipeline = __spreadArray(__spreadArray([], pipeline, true), ProjectFlowItem_1.default.execute(params.select), true);
73
+ if ((_b = params.posSteps) === null || _b === void 0 ? void 0 : _b.length) {
74
+ pipeline = __spreadArray(__spreadArray([], pipeline, true), params.posSteps, true);
75
+ }
69
76
  return [4 /*yield*/, model.aggregate(__spreadArray(__spreadArray([], MatchFlowItem_1.default.execute(params, model), true), pipeline, true), {
70
77
  collation: {
71
78
  locale: "pt",
@@ -73,7 +80,7 @@ var GetOneByFilterV3Flow = /** @class */ (function () {
73
80
  }
74
81
  }).read('secondaryPreferred')];
75
82
  case 1:
76
- result = _a.sent();
83
+ result = _c.sent();
77
84
  return [2 /*return*/, result[0]];
78
85
  }
79
86
  });
@@ -4,7 +4,7 @@ export interface IParams {
4
4
  [key: string]: any;
5
5
  mainFilter: any;
6
6
  preSteps?: any[];
7
- postSteps?: any[];
7
+ posSteps?: any[];
8
8
  }
9
9
  declare class SearcherV3Flow {
10
10
  exec(params: IParams, model: mongoose.Model<any>, oneToMany?: IForeingData[]): Promise<any>;
@@ -80,8 +80,8 @@ var SearcherV3Flow = /** @class */ (function () {
80
80
  pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), MatchFlowItem_1.default.execute(params, model), true);
81
81
  pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), SortFlowItem_1.default.execute(params.orderBy, params.orderSense), true);
82
82
  pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), ProjectFlowItem_1.default.execute(params.select), true);
83
- if ((_d = params.postSteps) === null || _d === void 0 ? void 0 : _d.length) {
84
- pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), params.postSteps, true);
83
+ if ((_d = params.posSteps) === null || _d === void 0 ? void 0 : _d.length) {
84
+ pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), params.posSteps, true);
85
85
  }
86
86
  if (params.pageable !== false) {
87
87
  pipelineFacetItems = __spreadArray(__spreadArray([], pipelineFacetItems, true), [
@@ -50,7 +50,9 @@ var BuildAndQueriesFlowItem = /** @class */ (function () {
50
50
  'searchTextFields',
51
51
  'sort',
52
52
  'isPageable',
53
- 'searchPageable'
53
+ 'searchPageable',
54
+ 'preSteps',
55
+ 'posSteps',
54
56
  ].includes(key)) {
55
57
  return;
56
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.402",
3
+ "version": "2.1.404",
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",
@@ -3,18 +3,26 @@ import OneToManyFlowItem, { IForeingData } from "./item/OneToManyFlowItem"
3
3
  import PopulateFlowItem from "./item/PopulateFlowItem"
4
4
  import ProjectFlowItem from "./item/ProjectFlowItem"
5
5
  import MatchFlowItem from "./item/MatchFlowItem"
6
+ import { IParams } from "./SearcherV3Flow"
6
7
 
7
8
 
8
9
 
9
10
  class GetOneByFilterV3Flow {
10
11
 
11
- async exec(params: any, model: mongoose.Model<any>, oneToMany: IForeingData[] = []) {
12
+ async exec(params: IParams, model: mongoose.Model<any>, oneToMany: IForeingData[] = []) {
12
13
 
13
14
  let pipeline: any[] = []
15
+ if (params.preSteps?.length) {
16
+ pipeline = [...pipeline, ...params.preSteps]
17
+ }
14
18
  pipeline = [...pipeline, ...PopulateFlowItem.execute(params.populate, model)]
15
19
  pipeline = [...pipeline, ...OneToManyFlowItem.execute(oneToMany, params.populate)]
16
20
  pipeline = [...pipeline, ...ProjectFlowItem.execute(params.select)]
17
21
 
22
+ if (params.posSteps?.length) {
23
+ pipeline = [...pipeline, ...params.posSteps]
24
+ }
25
+
18
26
  let result = await model.aggregate([
19
27
  ...MatchFlowItem.execute(params, model),
20
28
  ...pipeline
@@ -11,7 +11,7 @@ export interface IParams {
11
11
  [key: string]: any
12
12
  mainFilter: any
13
13
  preSteps?: any[]
14
- postSteps?: any[]
14
+ posSteps?: any[]
15
15
  }
16
16
 
17
17
  class SearcherV3Flow {
@@ -36,8 +36,8 @@ class SearcherV3Flow {
36
36
  pipelineFacetItems = [...pipelineFacetItems, ...SortFlowItem.execute(params.orderBy, params.orderSense)]
37
37
  pipelineFacetItems = [...pipelineFacetItems, ...ProjectFlowItem.execute(params.select)]
38
38
 
39
- if (params.postSteps?.length) {
40
- pipelineFacetItems = [...pipelineFacetItems, ...params.postSteps]
39
+ if (params.posSteps?.length) {
40
+ pipelineFacetItems = [...pipelineFacetItems, ...params.posSteps]
41
41
  }
42
42
 
43
43
  if (params.pageable !== false) {
@@ -32,7 +32,10 @@ class BuildAndQueriesFlowItem {
32
32
  'searchTextFields',
33
33
  'sort',
34
34
  'isPageable',
35
- 'searchPageable'].includes(key)) {
35
+ 'searchPageable',
36
+ 'preSteps',
37
+ 'posSteps',
38
+ ].includes(key)) {
36
39
  return
37
40
  }
38
41