c2-mongoose 2.1.22 → 2.1.23

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.
@@ -9,11 +9,11 @@ declare abstract class SearchFlow {
9
9
  select: string;
10
10
  populate: any;
11
11
  filters: any;
12
+ pageable: boolean;
12
13
  constructor(params: any);
13
14
  buildPopulate(): any;
14
15
  buildPath(target: string, nested?: string): any;
15
16
  buildOrdenation(): any;
16
- private isPageable;
17
17
  diacriticSensitiveRegex(string?: string): string;
18
18
  search(model: mongoose.Model<any>): Promise<SearchResponse<any>>;
19
19
  private searchPageable;
@@ -56,15 +56,7 @@ var Utils_1 = require("../utils/Utils");
56
56
  var SearchFlow = /** @class */ (function () {
57
57
  function SearchFlow(params) {
58
58
  var _this = this;
59
- this.isPageable = function () {
60
- if ((0, Utils_1.isEmpty)(_this.page)) {
61
- _this.page = 1;
62
- }
63
- if (_this.page >= 0) {
64
- return true;
65
- }
66
- return false;
67
- };
59
+ this.pageable = true;
68
60
  this.searchPageable = function (model) { return __awaiter(_this, void 0, void 0, function () {
69
61
  var sort, items;
70
62
  return __generator(this, function (_a) {
@@ -141,7 +133,7 @@ var SearchFlow = /** @class */ (function () {
141
133
  return __generator(this, function (_a) {
142
134
  switch (_a.label) {
143
135
  case 0:
144
- if (!this.isPageable()) return [3 /*break*/, 2];
136
+ if (!this.pageable) return [3 /*break*/, 2];
145
137
  return [4 /*yield*/, this.searchPageable(model)];
146
138
  case 1: return [2 /*return*/, _a.sent()];
147
139
  case 2: return [4 /*yield*/, this.searchNoPageable(model)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-mongoose",
3
- "version": "2.1.22",
3
+ "version": "2.1.23",
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",
@@ -13,6 +13,7 @@ abstract class SearchFlow {
13
13
  select: string
14
14
  populate: any
15
15
  filters: any
16
+ pageable: boolean = true
16
17
 
17
18
  constructor(params: any) {
18
19
  this.searchText = params.searchText || ""
@@ -59,18 +60,6 @@ abstract class SearchFlow {
59
60
  return order
60
61
  }
61
62
 
62
- private isPageable = () => {
63
- if (isEmpty(this.page)) {
64
- this.page = 1
65
- }
66
-
67
- if (this.page >= 0) {
68
- return true
69
- }
70
-
71
- return false
72
- }
73
-
74
63
  public diacriticSensitiveRegex(string: string = ""): string {
75
64
  return string
76
65
  .replace(/[a|á|à|ä|â|A|Á|Â|Ã|Ä]/g, '[a,á,à,ä,â,A,Á,Â,Ã,Ä]')
@@ -82,7 +71,7 @@ abstract class SearchFlow {
82
71
  }
83
72
 
84
73
  public async search(model: mongoose.Model<any>): Promise<SearchResponse<any>> {
85
- if (this.isPageable()) {
74
+ if (this.pageable) {
86
75
  return await this.searchPageable(model)
87
76
  }
88
77