c2-mongoose 2.1.415 → 2.1.417

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.
@@ -5,6 +5,7 @@ export interface IParams {
5
5
  mainFilter: any;
6
6
  preSteps?: any[];
7
7
  posSteps?: any[];
8
+ metadata?: Map<string, any[]>;
8
9
  }
9
10
  declare class SearcherV3Flow {
10
11
  exec(params: IParams, model: mongoose.Model<any>, oneToMany?: IForeingData[]): Promise<any>;
@@ -62,9 +62,9 @@ var SearcherV3Flow = /** @class */ (function () {
62
62
  var _a, _b, _c, _d, _e;
63
63
  if (oneToMany === void 0) { oneToMany = []; }
64
64
  return __awaiter(this, void 0, void 0, function () {
65
- var facet, pipelineFacetPaging, pipelineFacetItems, mainFilters, result, ret;
66
- return __generator(this, function (_f) {
67
- switch (_f.label) {
65
+ var facet, pipelineFacetPaging, pipelineFacetItems, _i, _f, _g, key, value, _h, value_1, item, mainFilters, result, ret;
66
+ return __generator(this, function (_j) {
67
+ switch (_j.label) {
68
68
  case 0:
69
69
  params.page = Number((_a = params.page) !== null && _a !== void 0 ? _a : 1);
70
70
  params.limit = Number((_b = params.limit) !== null && _b !== void 0 ? _b : 50);
@@ -88,10 +88,19 @@ var SearcherV3Flow = /** @class */ (function () {
88
88
  { $skip: (params.page - 1) * (params.limit) },
89
89
  { $limit: params.limit }
90
90
  ], false);
91
- pipelineFacetPaging = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], GroupFlowItem_1.default.execute(params.groupBy, params.sumFields, params.groupDetailed, model), true), OneToManyFlowItem_1.default.execute(oneToMany, params.populate), true), PopulateFlowItem_1.default.execute(params.populate, model), true), MatchFlowItem_1.default.execute(params, model), true), BuildPaginationDataFlowItem_1.default.execute(params.page, params.limit), true);
91
+ pipelineFacetPaging = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], GroupFlowItem_1.default.execute(params.groupBy, params.sumFields, params.groupDetailed, model), true), PopulateFlowItem_1.default.execute(params.populate, model), true), OneToManyFlowItem_1.default.execute(oneToMany, params.populate), true), MatchFlowItem_1.default.execute(params, model), true), BuildPaginationDataFlowItem_1.default.execute(params.page, params.limit), true);
92
92
  facet.paging = pipelineFacetPaging;
93
93
  }
94
94
  facet.items = pipelineFacetItems;
95
+ if (params.metadata) {
96
+ for (_i = 0, _f = Array.from(params.metadata.entries()); _i < _f.length; _i++) {
97
+ _g = _f[_i], key = _g[0], value = _g[1];
98
+ for (_h = 0, value_1 = value; _h < value_1.length; _h++) {
99
+ item = value_1[_h];
100
+ facet[key] = value;
101
+ }
102
+ }
103
+ }
95
104
  mainFilters = params.mainFilter ? __spreadArray([], MatchFlowItem_1.default.execute(params.mainFilter, model), true) : [];
96
105
  return [4 /*yield*/, model.aggregate(__spreadArray(__spreadArray([], mainFilters, true), [
97
106
  {
@@ -104,7 +113,7 @@ var SearcherV3Flow = /** @class */ (function () {
104
113
  }
105
114
  }).read('secondaryPreferred')];
106
115
  case 1:
107
- result = _f.sent();
116
+ result = _j.sent();
108
117
  ret = {};
109
118
  ret.items = result[0].items;
110
119
  if (params.pageable !== false) {
@@ -54,6 +54,7 @@ var BuildAndQueriesFlowItem = /** @class */ (function () {
54
54
  'searchPageable',
55
55
  'preSteps',
56
56
  'posSteps',
57
+ 'metadata'
57
58
  ].includes(key)) {
58
59
  return;
59
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.415",
3
+ "version": "2.1.417",
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",
@@ -12,6 +12,7 @@ export interface IParams {
12
12
  mainFilter: any
13
13
  preSteps?: any[]
14
14
  posSteps?: any[]
15
+ metadata?: Map<string, any[]>
15
16
  }
16
17
 
17
18
  class SearcherV3Flow {
@@ -49,8 +50,8 @@ class SearcherV3Flow {
49
50
 
50
51
  pipelineFacetPaging = [
51
52
  ...GroupFlowItem.execute(params.groupBy, params.sumFields, params.groupDetailed, model),
52
- ...OneToManyFlowItem.execute(oneToMany, params.populate),
53
53
  ...PopulateFlowItem.execute(params.populate, model),
54
+ ...OneToManyFlowItem.execute(oneToMany, params.populate),
54
55
  ...MatchFlowItem.execute(params, model),
55
56
  ...BuildPaginationDataFlowItem.execute(params.page, params.limit),
56
57
  ]
@@ -58,6 +59,14 @@ class SearcherV3Flow {
58
59
  }
59
60
  facet.items = pipelineFacetItems
60
61
 
62
+ if (params.metadata) {
63
+ for (const [key, value] of Array.from(params.metadata.entries())) {
64
+ for (const item of value) {
65
+ facet[key] = value
66
+ }
67
+ }
68
+ }
69
+
61
70
  const mainFilters = params.mainFilter ? [...MatchFlowItem.execute(params.mainFilter, model)] : []
62
71
 
63
72
  let result = await model.aggregate([
@@ -35,6 +35,7 @@ class BuildAndQueriesFlowItem {
35
35
  'searchPageable',
36
36
  'preSteps',
37
37
  'posSteps',
38
+ 'metadata'
38
39
  ].includes(key)) {
39
40
  return
40
41
  }