@axiosleo/orm-mysql 0.10.0 → 0.10.2
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.
- package/bin/orm-mysql.js +1 -1
- package/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/builder.js +2 -1
- package/src/query.js +13 -19
package/bin/orm-mysql.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -98,6 +98,10 @@ export declare class QueryCondition {
|
|
|
98
98
|
|
|
99
99
|
where(key: string, opt: OptType, value: ConditionValueType | WhereOptions[], isOr?: boolean): this;
|
|
100
100
|
|
|
101
|
+
whereAnd(): this;
|
|
102
|
+
|
|
103
|
+
whereOr(): this;
|
|
104
|
+
|
|
101
105
|
whereIn(key: string, value: string | string[] | number[] | Query): this;
|
|
102
106
|
|
|
103
107
|
whereNotIn(key: string, value: string | string[] | number[] | Query): this;
|
package/package.json
CHANGED
package/src/builder.js
CHANGED
|
@@ -276,7 +276,8 @@ class Builder {
|
|
|
276
276
|
`JSON_CONTAINS(JSON_ARRAY(?), JSON_EXTRACT(${k}, '${keys[1]}'))`;
|
|
277
277
|
return isNot ? `${sql}=0` : sql;
|
|
278
278
|
}
|
|
279
|
-
let
|
|
279
|
+
let v = is.string(condition.value) ? condition.value.split(',').map(v => v.trim()) : condition.value;
|
|
280
|
+
let res = this._buildConditionValues(v);
|
|
280
281
|
const opt = isNot ? 'NOT IN' : 'IN';
|
|
281
282
|
return res ? `${this._buildFieldKey(condition.key)} ${opt} (${res})` : `${this._buildFieldKey(condition.key)} ${opt} (?)`;
|
|
282
283
|
}
|
package/src/query.js
CHANGED
|
@@ -42,11 +42,11 @@ class QueryCondition {
|
|
|
42
42
|
case 4:
|
|
43
43
|
case 3: {
|
|
44
44
|
const [key, opt, value] = args;
|
|
45
|
-
if (is.string(value) && optType.includes(value.toUpperCase())
|
|
46
|
-
this.options.conditions.push({ key, opt: value, value: opt });
|
|
45
|
+
if (is.string(value) && optType.includes(value.toUpperCase())) {
|
|
46
|
+
this.options.conditions.push({ key, opt: value.toUpperCase(), value: opt });
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
|
-
this.options.conditions.push({ key, opt, value });
|
|
49
|
+
this.options.conditions.push({ key, opt: opt.toUpperCase(), value });
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
52
|
case 2: {
|
|
@@ -77,48 +77,42 @@ class QueryCondition {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
whereIn(key, value) {
|
|
80
|
-
|
|
81
|
-
value = value.split(',').map(v => v.trim());
|
|
82
|
-
}
|
|
83
|
-
this.options.conditions.push({ key, opt: 'IN', value });
|
|
80
|
+
this.where(key, 'IN', value);
|
|
84
81
|
return this;
|
|
85
82
|
}
|
|
86
83
|
|
|
87
84
|
whereNotIn(key, value) {
|
|
88
|
-
|
|
89
|
-
value = value.split(',').map(v => v.trim());
|
|
90
|
-
}
|
|
91
|
-
this.options.conditions.push({ key, opt: 'NOT IN', value });
|
|
85
|
+
this.where(key, 'NOT IN', value);
|
|
92
86
|
return this;
|
|
93
87
|
}
|
|
94
88
|
|
|
95
89
|
whereContain(key, value) {
|
|
96
|
-
this.
|
|
90
|
+
this.where(key, 'CONTAIN', value);
|
|
97
91
|
return this;
|
|
98
92
|
}
|
|
99
93
|
|
|
100
94
|
whereNotContain(key, value) {
|
|
101
|
-
this.
|
|
95
|
+
this.where(key, 'NOT CONTAIN', value);
|
|
102
96
|
return this;
|
|
103
97
|
}
|
|
104
98
|
|
|
105
99
|
whereBetween(key, value) {
|
|
106
|
-
this.
|
|
100
|
+
this.where(key, 'BETWEEN', value);
|
|
107
101
|
return this;
|
|
108
102
|
}
|
|
109
103
|
|
|
110
104
|
whereNotBetween(key, value) {
|
|
111
|
-
this.
|
|
105
|
+
this.where(key, 'NOT BETWEEN', value);
|
|
112
106
|
return this;
|
|
113
107
|
}
|
|
114
108
|
|
|
115
109
|
whereOverlaps(key, value) {
|
|
116
|
-
this.
|
|
110
|
+
this.where(key, 'OVERLAPS', value);
|
|
117
111
|
return this;
|
|
118
112
|
}
|
|
119
113
|
|
|
120
114
|
whereNotOverlaps(key, value) {
|
|
121
|
-
this.
|
|
115
|
+
this.where(key, 'NOT OVERLAPS', value);
|
|
122
116
|
return this;
|
|
123
117
|
}
|
|
124
118
|
|
|
@@ -126,7 +120,7 @@ class QueryCondition {
|
|
|
126
120
|
if (is.array(value)) {
|
|
127
121
|
value = value.join('');
|
|
128
122
|
}
|
|
129
|
-
this.
|
|
123
|
+
this.where(key, 'LIKE', value);
|
|
130
124
|
return this;
|
|
131
125
|
}
|
|
132
126
|
|
|
@@ -134,7 +128,7 @@ class QueryCondition {
|
|
|
134
128
|
if (is.array(value)) {
|
|
135
129
|
value = value.join('');
|
|
136
130
|
}
|
|
137
|
-
this.
|
|
131
|
+
this.where(key, 'NOT LIKE', value);
|
|
138
132
|
return this;
|
|
139
133
|
}
|
|
140
134
|
|