wok-server 0.1.6 → 0.1.7
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.
|
@@ -102,6 +102,15 @@ class MysqlCriteria {
|
|
|
102
102
|
this.criteria.push({ type: 'in', columnName: column, value: values });
|
|
103
103
|
return this;
|
|
104
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* not in 条件
|
|
107
|
+
* @param column
|
|
108
|
+
* @param values
|
|
109
|
+
*/
|
|
110
|
+
notIn(column, values) {
|
|
111
|
+
this.criteria.push({ type: 'notIn', columnName: column, value: values });
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
105
114
|
/**
|
|
106
115
|
* 嵌入其它的查询条件,与现有的查询条件是或者关系.
|
|
107
116
|
* @param criteria
|
|
@@ -165,12 +174,12 @@ class MysqlCriteria {
|
|
|
165
174
|
if (criterion.type === 'isNull' || criterion.type === 'isNotNull') {
|
|
166
175
|
continue;
|
|
167
176
|
}
|
|
168
|
-
if (criterion.type === 'in') {
|
|
177
|
+
if (criterion.type === 'in' || criterion.type === 'notIn') {
|
|
169
178
|
if (!Array.isArray(criterion.value)) {
|
|
170
|
-
throw new exception_1.MysqlException(`Invalid
|
|
179
|
+
throw new exception_1.MysqlException(`Invalid ${criterion.type} condition,the condition value is not a array type,column name:${criterion.columnName.toString()}`);
|
|
171
180
|
}
|
|
172
181
|
if (!criterion.value.length) {
|
|
173
|
-
throw new exception_1.MysqlException(`Invalid
|
|
182
|
+
throw new exception_1.MysqlException(`Invalid ${criterion.type} condition,the condition value cannot be an empty array,column name:${criterion.columnName.toString()}`);
|
|
174
183
|
}
|
|
175
184
|
continue;
|
|
176
185
|
}
|
|
@@ -230,6 +239,9 @@ class MysqlCriteria {
|
|
|
230
239
|
else if (criterion.type === 'in') {
|
|
231
240
|
sign = 'in';
|
|
232
241
|
}
|
|
242
|
+
else if (criterion.type === 'notIn') {
|
|
243
|
+
sign = 'not in';
|
|
244
|
+
}
|
|
233
245
|
else if (criterion.type === 'like') {
|
|
234
246
|
sign = 'like';
|
|
235
247
|
}
|
|
@@ -237,7 +249,7 @@ class MysqlCriteria {
|
|
|
237
249
|
sign = 'not like';
|
|
238
250
|
}
|
|
239
251
|
if (sign) {
|
|
240
|
-
if (criterion.type === 'in') {
|
|
252
|
+
if (criterion.type === 'in' || criterion.type === 'notIn') {
|
|
241
253
|
sqlFragments.push(`and ?? ${sign} (?) `);
|
|
242
254
|
}
|
|
243
255
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wok-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"packageManager": "pnpm@8.9.0",
|
|
5
5
|
"description": "一个基于 NodeJs 和 TypeScript 的后端框架,轻量级、克制、简洁。A lightweight, restrained, and concise backend framework based on Node.js and TypeScript.",
|
|
6
6
|
"scripts": {
|
|
@@ -72,6 +72,12 @@ export declare class MysqlCriteria<T> {
|
|
|
72
72
|
* @param values
|
|
73
73
|
*/
|
|
74
74
|
in(column: keyof T, values: Array<string | number>): this;
|
|
75
|
+
/**
|
|
76
|
+
* not in 条件
|
|
77
|
+
* @param column
|
|
78
|
+
* @param values
|
|
79
|
+
*/
|
|
80
|
+
notIn(column: keyof T, values: Array<string | number>): this;
|
|
75
81
|
/**
|
|
76
82
|
* 嵌入其它的查询条件,与现有的查询条件是或者关系.
|
|
77
83
|
* @param criteria
|