@joktec/mysql 0.0.30 → 0.0.32

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.
@@ -1,55 +1,55 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertOp = exports.preHandleQuery = void 0;
4
- const sequelize_1 = require("sequelize");
5
- const preHandleQuery = (condition, keyword) => {
6
- const where = {};
7
- for (const [key, value] of Object.entries(condition)) {
8
- if (key === '$and') {
9
- where[sequelize_1.Op.and] = value.map(c => (0, exports.preHandleQuery)(c));
10
- }
11
- else if (key === '$or') {
12
- where[sequelize_1.Op.or] = value.map(c => (0, exports.preHandleQuery)(c));
13
- }
14
- else if (typeof value === 'object') {
15
- const entries = Object.entries(value);
16
- for (const [op, val] of entries) {
17
- const sqlOp = (0, exports.convertOp)(op);
18
- where[key] = Object.assign(Object.assign({}, where[key]), { [sqlOp]: val });
19
- }
20
- }
21
- else {
22
- where[key] = value;
23
- }
24
- }
25
- if (keyword) {
26
- Object.entries(keyword).map(([key, value]) => {
27
- where[key] = { [sequelize_1.Op.substring]: value };
28
- });
29
- }
30
- return { where };
31
- };
32
- exports.preHandleQuery = preHandleQuery;
33
- const convertOp = (op) => {
34
- switch (op) {
35
- case '$ne':
36
- return sequelize_1.Op.ne;
37
- case '$gt':
38
- return sequelize_1.Op.gt;
39
- case '$gte':
40
- return sequelize_1.Op.gte;
41
- case '$lt':
42
- return sequelize_1.Op.lt;
43
- case '$lte':
44
- return sequelize_1.Op.lte;
45
- case '$in':
46
- return sequelize_1.Op.in;
47
- case '$nin':
48
- return sequelize_1.Op.notIn;
49
- case '$eq':
50
- default:
51
- return sequelize_1.Op.eq;
52
- }
53
- };
54
- exports.convertOp = convertOp;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertOp = exports.preHandleQuery = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ const preHandleQuery = (condition, keyword) => {
6
+ const where = {};
7
+ for (const [key, value] of Object.entries(condition)) {
8
+ if (key === '$and') {
9
+ where[sequelize_1.Op.and] = value.map(c => (0, exports.preHandleQuery)(c));
10
+ }
11
+ else if (key === '$or') {
12
+ where[sequelize_1.Op.or] = value.map(c => (0, exports.preHandleQuery)(c));
13
+ }
14
+ else if (typeof value === 'object') {
15
+ const entries = Object.entries(value);
16
+ for (const [op, val] of entries) {
17
+ const sqlOp = (0, exports.convertOp)(op);
18
+ where[key] = Object.assign(Object.assign({}, where[key]), { [sqlOp]: val });
19
+ }
20
+ }
21
+ else {
22
+ where[key] = value;
23
+ }
24
+ }
25
+ if (keyword) {
26
+ Object.entries(keyword).map(([key, value]) => {
27
+ where[key] = { [sequelize_1.Op.substring]: value };
28
+ });
29
+ }
30
+ return { where };
31
+ };
32
+ exports.preHandleQuery = preHandleQuery;
33
+ const convertOp = (op) => {
34
+ switch (op) {
35
+ case '$ne':
36
+ return sequelize_1.Op.ne;
37
+ case '$gt':
38
+ return sequelize_1.Op.gt;
39
+ case '$gte':
40
+ return sequelize_1.Op.gte;
41
+ case '$lt':
42
+ return sequelize_1.Op.lt;
43
+ case '$lte':
44
+ return sequelize_1.Op.lte;
45
+ case '$in':
46
+ return sequelize_1.Op.in;
47
+ case '$nin':
48
+ return sequelize_1.Op.notIn;
49
+ case '$eq':
50
+ default:
51
+ return sequelize_1.Op.eq;
52
+ }
53
+ };
54
+ exports.convertOp = convertOp;
55
55
  //# sourceMappingURL=mysql.utils.js.map