asv-hlps 1.4.59 → 1.4.61

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 HlpQuery {
18
18
  qProp: string | number;
19
19
  qOn?: any;
20
20
  }) => void;
21
+ search: (qb: any, columns: string[], search: string) => void;
21
22
  }
22
23
  declare const _default: HlpQuery;
23
24
  export default _default;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const typeorm_1 = require("../npms/typeorm");
3
+ const typeorm_1 = require("typeorm");
4
+ const typeorm_2 = require("../npms/typeorm");
4
5
  class HlpQuery {
5
6
  constructor() {
6
7
  this.where = (qb, column, prm, qOn) => {
@@ -50,7 +51,7 @@ class HlpQuery {
50
51
  this.opDate = (qb, column, prm) => {
51
52
  var _a, _b, _c;
52
53
  if (prm === null || prm === void 0 ? void 0 : prm.opDate) {
53
- (0, typeorm_1.tormDateParams)(qb, `${column}`, (_a = prm === null || prm === void 0 ? void 0 : prm.opDate) === null || _a === void 0 ? void 0 : _a.eDate, (_b = prm === null || prm === void 0 ? void 0 : prm.opDate) === null || _b === void 0 ? void 0 : _b.dates, (_c = prm === null || prm === void 0 ? void 0 : prm.opDate) === null || _c === void 0 ? void 0 : _c.datesBy);
54
+ (0, typeorm_2.tormDateParams)(qb, `${column}`, (_a = prm === null || prm === void 0 ? void 0 : prm.opDate) === null || _a === void 0 ? void 0 : _a.eDate, (_b = prm === null || prm === void 0 ? void 0 : prm.opDate) === null || _b === void 0 ? void 0 : _b.dates, (_c = prm === null || prm === void 0 ? void 0 : prm.opDate) === null || _c === void 0 ? void 0 : _c.datesBy);
54
55
  }
55
56
  };
56
57
  this.join = (qb, column, rStr, status = "ljs") => {
@@ -67,6 +68,25 @@ class HlpQuery {
67
68
  qb.andWhere(`${joker.column} = :${qVar}`, { [qVar]: joker["qProp"] });
68
69
  }
69
70
  };
71
+ this.search = (qb, columns, search) => {
72
+ if (search) {
73
+ qb.andWhere(new typeorm_1.Brackets(qb => {
74
+ columns.forEach((column, index) => {
75
+ const columnRef = column.substring(column.indexOf(".") + 1);
76
+ if (index === 0) {
77
+ qb.where(`${column} LIKE :${columnRef}`, { [columnRef]: "%" + search + "%" });
78
+ }
79
+ else {
80
+ qb.orWhere(`${column} LIKE :${columnRef}`, { [columnRef]: "%" + search + "%" });
81
+ }
82
+ });
83
+ // for (const column of columns) {
84
+ // const columnRef = column.substring(column.indexOf(".") + 1);
85
+ // qb.where(`${column} LIKE :${columnRef}`, { [columnRef]: "%" + search + "%" });
86
+ // }
87
+ }));
88
+ }
89
+ };
70
90
  }
71
91
  }
72
92
  exports.default = new HlpQuery();
@@ -18,6 +18,7 @@ declare class HlpQuery {
18
18
  qProp: string | number;
19
19
  qOn?: any;
20
20
  }) => void;
21
+ search: (qb: any, columns: string[], search: string) => void;
21
22
  }
22
23
  declare const _default: HlpQuery;
23
24
  export default _default;
@@ -1,3 +1,4 @@
1
+ import { Brackets } from "typeorm";
1
2
  import { tormDateParams } from "../npms/typeorm";
2
3
  class HlpQuery {
3
4
  constructor() {
@@ -65,6 +66,25 @@ class HlpQuery {
65
66
  qb.andWhere(`${joker.column} = :${qVar}`, { [qVar]: joker["qProp"] });
66
67
  }
67
68
  };
69
+ this.search = (qb, columns, search) => {
70
+ if (search) {
71
+ qb.andWhere(new Brackets(qb => {
72
+ columns.forEach((column, index) => {
73
+ const columnRef = column.substring(column.indexOf(".") + 1);
74
+ if (index === 0) {
75
+ qb.where(`${column} LIKE :${columnRef}`, { [columnRef]: "%" + search + "%" });
76
+ }
77
+ else {
78
+ qb.orWhere(`${column} LIKE :${columnRef}`, { [columnRef]: "%" + search + "%" });
79
+ }
80
+ });
81
+ // for (const column of columns) {
82
+ // const columnRef = column.substring(column.indexOf(".") + 1);
83
+ // qb.where(`${column} LIKE :${columnRef}`, { [columnRef]: "%" + search + "%" });
84
+ // }
85
+ }));
86
+ }
87
+ };
68
88
  }
69
89
  }
70
90
  export default new HlpQuery();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asv-hlps",
3
- "version": "1.4.59",
3
+ "version": "1.4.61",
4
4
  "description": "helpers",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",