c2-mongoose 2.1.416 → 2.1.418

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, mainFilters, result, ret;
66
+ return __generator(this, function (_h) {
67
+ switch (_h.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);
@@ -92,6 +92,12 @@ var SearcherV3Flow = /** @class */ (function () {
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
+ facet[key] = value;
99
+ }
100
+ }
95
101
  mainFilters = params.mainFilter ? __spreadArray([], MatchFlowItem_1.default.execute(params.mainFilter, model), true) : [];
96
102
  return [4 /*yield*/, model.aggregate(__spreadArray(__spreadArray([], mainFilters, true), [
97
103
  {
@@ -104,7 +110,7 @@ var SearcherV3Flow = /** @class */ (function () {
104
110
  }
105
111
  }).read('secondaryPreferred')];
106
112
  case 1:
107
- result = _f.sent();
113
+ result = _h.sent();
108
114
  ret = {};
109
115
  ret.items = result[0].items;
110
116
  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.416",
3
+ "version": "2.1.418",
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 {
@@ -58,6 +59,12 @@ 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
+ facet[key] = value
65
+ }
66
+ }
67
+
61
68
  const mainFilters = params.mainFilter ? [...MatchFlowItem.execute(params.mainFilter, model)] : []
62
69
 
63
70
  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
  }