@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 CHANGED
@@ -9,7 +9,7 @@ const app = new App({
9
9
  name: 'MySQL ORM CLI',
10
10
  desc: 'migrate, model, seed, etc.',
11
11
  bin: 'orm-mysql',
12
- version: '0.10.0',
12
+ version: '0.10.2',
13
13
  commands_dir: path.join(__dirname, '../commands'),
14
14
  });
15
15
 
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiosleo/orm-mysql",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "MySQL ORM tool",
5
5
  "keywords": [
6
6
  "mysql",
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 res = this._buildConditionValues(condition.value);
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()) >= -1) {
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
- if (is.string(value)) {
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
- if (is.string(value)) {
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.options.conditions.push({ key, opt: 'CONTAIN', value });
90
+ this.where(key, 'CONTAIN', value);
97
91
  return this;
98
92
  }
99
93
 
100
94
  whereNotContain(key, value) {
101
- this.options.conditions.push({ key, opt: 'NOT CONTAIN', value });
95
+ this.where(key, 'NOT CONTAIN', value);
102
96
  return this;
103
97
  }
104
98
 
105
99
  whereBetween(key, value) {
106
- this.options.conditions.push({ key, opt: 'BETWEEN', value });
100
+ this.where(key, 'BETWEEN', value);
107
101
  return this;
108
102
  }
109
103
 
110
104
  whereNotBetween(key, value) {
111
- this.options.conditions.push({ key, opt: 'NOT BETWEEN', value });
105
+ this.where(key, 'NOT BETWEEN', value);
112
106
  return this;
113
107
  }
114
108
 
115
109
  whereOverlaps(key, value) {
116
- this.options.conditions.push({ key, opt: 'OVERLAPS', value });
110
+ this.where(key, 'OVERLAPS', value);
117
111
  return this;
118
112
  }
119
113
 
120
114
  whereNotOverlaps(key, value) {
121
- this.options.conditions.push({ key, opt: 'NOT OVERLAPS', value });
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.options.conditions.push({ key, opt: 'LIKE', value });
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.options.conditions.push({ key, opt: 'NOT LIKE', value });
131
+ this.where(key, 'NOT LIKE', value);
138
132
  return this;
139
133
  }
140
134