c2-mongoose 2.1.216 → 2.1.218

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.
@@ -18,6 +18,7 @@ declare class SearcherFlow<D> {
18
18
  private pageable;
19
19
  private selection;
20
20
  private populate;
21
+ private filters;
21
22
  constructor(repository: mongoose.Model<any>, search?: SearchFlow);
22
23
  prepareSearch(search: any): void;
23
24
  search(model: mongoose.Model<any>, options: SearchOptions): Promise<SearchResponse<D>>;
@@ -50,11 +50,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
+ var moment_1 = __importDefault(require("moment"));
53
54
  var mongoose_1 = require("mongoose");
54
55
  var Utils_1 = require("../utils/Utils");
55
- var BuildSelectSingleFlowItem_1 = __importDefault(require("./item/BuildSelectSingleFlowItem"));
56
56
  var BuildPopulateSingleFlowItem_1 = __importDefault(require("./item/BuildPopulateSingleFlowItem"));
57
- var moment_1 = __importDefault(require("moment"));
57
+ var BuildSelectSingleFlowItem_1 = __importDefault(require("./item/BuildSelectSingleFlowItem"));
58
58
  var SearcherFlow = /** @class */ (function () {
59
59
  function SearcherFlow(repository, search) {
60
60
  this.searchText = "";
@@ -65,6 +65,7 @@ var SearcherFlow = /** @class */ (function () {
65
65
  this.pageable = true;
66
66
  this.selection = [""];
67
67
  this.populate = [""];
68
+ this.filters = undefined;
68
69
  this.model = repository;
69
70
  for (var key in search) {
70
71
  this[key] = search[key];
@@ -74,6 +75,7 @@ var SearcherFlow = /** @class */ (function () {
74
75
  for (var key in search) {
75
76
  this[key] = search[key];
76
77
  }
78
+ this.filters = this.buildDefaultFilters(this);
77
79
  // this.projection = this.buildProjections()
78
80
  // this.populate = this.buildPopulate()
79
81
  // this.buildOrdenation()
@@ -84,6 +86,7 @@ var SearcherFlow = /** @class */ (function () {
84
86
  return __generator(this, function (_b) {
85
87
  switch (_b.label) {
86
88
  case 0:
89
+ console.log("new searcher");
87
90
  stagesItems = [];
88
91
  if ((0, Utils_1.isNotEmpty)(options.pipelines)) {
89
92
  stagesItems.push.apply(stagesItems, options.pipelines);
@@ -93,7 +96,7 @@ var SearcherFlow = /** @class */ (function () {
93
96
  }
94
97
  stagesItems.push({ $match: this.filters });
95
98
  if ((0, Utils_1.isNotEmpty)(this.projection)) {
96
- stagesItems.push({ $project: BuildSelectSingleFlowItem_1.default.build(model, this.select) });
99
+ stagesItems.push({ $project: BuildSelectSingleFlowItem_1.default.build(model, this.selection) });
97
100
  }
98
101
  // stagesItems.push({ $sort: this.sort })
99
102
  if (this.pageable === true) {
@@ -198,7 +201,7 @@ var SearcherFlow = /** @class */ (function () {
198
201
  'page',
199
202
  'limit',
200
203
  'model',
201
- 'select',
204
+ 'selection',
202
205
  'searchText',
203
206
  'sort',
204
207
  'isPageable',
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import C2Flow from "./flow/C2Flow";
2
2
  import CrudFlow from "./flow/CrudFlow";
3
3
  import SearchFlow from "./flow/SearchFlow";
4
+ import SearcherFlow from "./flow/SearcherFlow";
4
5
  import AddStagePaginationFlowItem from "./flow/item/AddStagePaginationFlowItem";
5
6
  import AddStageSortFlowItem from "./flow/item/AddStageSortFlowItem";
6
7
  import BuildPipelineToCountJoinFlowItem from "./flow/item/BuildPipelineToCountJoinFlowItem";
@@ -11,4 +12,4 @@ import { ILogger, LoggerModel, LoggerSearch, TypeOfOperation } from "./model/Log
11
12
  import { Options } from "./types/Options";
12
13
  import { Pagination, SearchResponse } from "./types/SearchResponse";
13
14
  import { initialize } from "./utils/Utils";
14
- export { AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize };
15
+ export { SearcherFlow, AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize };
package/dist/index.js CHANGED
@@ -3,13 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.initialize = exports.TypeOfOperation = exports.SearchFlow = exports.LoggerSearch = exports.LoggerModel = exports.CrudFlow = exports.ConvertToSearchResponseFlowItem = exports.C2Flow = exports.BuildPipelineToJoinFlowItem = exports.BuildPipelineToCountJoinFlowItem = exports.AddStageSortFlowItem = exports.AddStagePaginationFlowItem = void 0;
6
+ exports.initialize = exports.TypeOfOperation = exports.SearchFlow = exports.LoggerSearch = exports.LoggerModel = exports.CrudFlow = exports.ConvertToSearchResponseFlowItem = exports.C2Flow = exports.BuildPipelineToJoinFlowItem = exports.BuildPipelineToCountJoinFlowItem = exports.AddStageSortFlowItem = exports.AddStagePaginationFlowItem = exports.SearcherFlow = void 0;
7
7
  var C2Flow_1 = __importDefault(require("./flow/C2Flow"));
8
8
  exports.C2Flow = C2Flow_1.default;
9
9
  var CrudFlow_1 = __importDefault(require("./flow/CrudFlow"));
10
10
  exports.CrudFlow = CrudFlow_1.default;
11
11
  var SearchFlow_1 = __importDefault(require("./flow/SearchFlow"));
12
12
  exports.SearchFlow = SearchFlow_1.default;
13
+ var SearcherFlow_1 = __importDefault(require("./flow/SearcherFlow"));
14
+ exports.SearcherFlow = SearcherFlow_1.default;
13
15
  var AddStagePaginationFlowItem_1 = __importDefault(require("./flow/item/AddStagePaginationFlowItem"));
14
16
  exports.AddStagePaginationFlowItem = AddStagePaginationFlowItem_1.default;
15
17
  var AddStageSortFlowItem_1 = __importDefault(require("./flow/item/AddStageSortFlowItem"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.216",
3
+ "version": "2.1.218",
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",
@@ -1,10 +1,10 @@
1
+ import moment from "moment"
1
2
  import mongoose, { ClientSession, Types } from "mongoose"
2
3
  import { SearchOptions, SearchResponse } from "../types/SearchResponse"
3
- import { isEmpty, isNotEmpty } from "../utils/Utils"
4
+ import { isNotEmpty } from "../utils/Utils"
4
5
  import SearchFlow from "./SearchFlow"
5
- import BuildSelectSingleFlowItem from "./item/BuildSelectSingleFlowItem"
6
6
  import BuildPopulateSingleFlowItem from "./item/BuildPopulateSingleFlowItem"
7
- import moment from "moment"
7
+ import BuildSelectSingleFlowItem from "./item/BuildSelectSingleFlowItem"
8
8
  export interface IPopulate {
9
9
  [key: string]: any
10
10
  path: string
@@ -26,6 +26,7 @@ class SearcherFlow<D> {
26
26
 
27
27
  private selection: string[] = [""]
28
28
  private populate: string[] = [""]
29
+ private filters: any = undefined
29
30
 
30
31
  constructor(repository: mongoose.Model<any>, search?: SearchFlow) {
31
32
  this.model = repository
@@ -39,6 +40,8 @@ class SearcherFlow<D> {
39
40
  this[key] = search[key];
40
41
  }
41
42
 
43
+ this.filters = this.buildDefaultFilters(this)
44
+
42
45
  // this.projection = this.buildProjections()
43
46
  // this.populate = this.buildPopulate()
44
47
  // this.buildOrdenation()
@@ -46,6 +49,7 @@ class SearcherFlow<D> {
46
49
 
47
50
  async search(model: mongoose.Model<any>, options: SearchOptions): Promise<SearchResponse<D>> {
48
51
 
52
+ console.log("new searcher")
49
53
  let stagesItems: any[] = []
50
54
 
51
55
  if (isNotEmpty(options.pipelines)) {
@@ -58,7 +62,7 @@ class SearcherFlow<D> {
58
62
  stagesItems.push({ $match: this.filters })
59
63
 
60
64
  if (isNotEmpty(this.projection)) {
61
- stagesItems.push({ $project: BuildSelectSingleFlowItem.build(model, this.select) })
65
+ stagesItems.push({ $project: BuildSelectSingleFlowItem.build(model, this.selection) })
62
66
  }
63
67
 
64
68
  // stagesItems.push({ $sort: this.sort })
@@ -171,7 +175,7 @@ class SearcherFlow<D> {
171
175
  'page',
172
176
  'limit',
173
177
  'model',
174
- 'select',
178
+ 'selection',
175
179
  'searchText',
176
180
  'sort',
177
181
  'isPageable',
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import C2Flow from "./flow/C2Flow"
2
2
  import CrudFlow from "./flow/CrudFlow"
3
3
  import SearchFlow from "./flow/SearchFlow"
4
+ import SearcherFlow from "./flow/SearcherFlow"
4
5
  import AddStagePaginationFlowItem from "./flow/item/AddStagePaginationFlowItem"
5
6
  import AddStageSortFlowItem from "./flow/item/AddStageSortFlowItem"
6
7
  import BuildPipelineToCountJoinFlowItem from "./flow/item/BuildPipelineToCountJoinFlowItem"
@@ -14,5 +15,5 @@ import { initialize } from "./utils/Utils"
14
15
 
15
16
  (global as any).LoggerRepository = undefined
16
17
 
17
- export { AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize }
18
+ export { SearcherFlow, AddStagePaginationFlowItem, AddStageSortFlowItem, BuildPipelineToCountJoinFlowItem, BuildPipelineToJoinFlowItem, C2Flow, ConvertToSearchResponseFlowItem, CrudFlow, IFacet, ILogger, LoggerModel, LoggerSearch, Options, Pagination, SearchFlow, SearchResponse, TypeOfOperation, initialize }
18
19