@axiosleo/orm-mysql 0.9.8 → 0.9.9
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 +1 -1
- package/package.json +1 -1
- package/src/builder.js +2 -3
- package/src/query.js +5 -11
package/bin/orm-mysql.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -101,7 +101,7 @@ export declare class Query {
|
|
|
101
101
|
|
|
102
102
|
andWhere(key: string | null, opt: OptType, value: ConditionValueType | WhereOptions[]): this;
|
|
103
103
|
|
|
104
|
-
attr(...attr: Attr[]): this;
|
|
104
|
+
attr(...attr: Attr[] | Attr[][]): this;
|
|
105
105
|
|
|
106
106
|
orderBy(sortField: string, sortOrder: 'asc' | 'desc'): this;
|
|
107
107
|
|
package/package.json
CHANGED
package/src/builder.js
CHANGED
|
@@ -371,9 +371,6 @@ class ManageSQLBuilder extends Builder {
|
|
|
371
371
|
if (is.empty(options.columns)) {
|
|
372
372
|
throw new Error('At least one column is required');
|
|
373
373
|
}
|
|
374
|
-
if (!Object.values(options.columns).find(c => c.primaryKey === true)) {
|
|
375
|
-
throw new Error('At least one primary key column is required');
|
|
376
|
-
}
|
|
377
374
|
let columns = Object.keys(options.columns).map(name => {
|
|
378
375
|
return { name, ...options.columns[name] };
|
|
379
376
|
});
|
|
@@ -550,6 +547,8 @@ class ManageSQLBuilder extends Builder {
|
|
|
550
547
|
str += '(11)';
|
|
551
548
|
} else if (type === 'VARCHAR') {
|
|
552
549
|
str += '(255)';
|
|
550
|
+
} else if (type === 'TINYINT') {
|
|
551
|
+
str += '(4)';
|
|
553
552
|
}
|
|
554
553
|
if (options.allowNull === false) {
|
|
555
554
|
str += ' NOT NULL';
|
package/src/query.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const { _assign } = require('@axiosleo/cli-tool/src/helper/obj');
|
|
4
4
|
const { _validate } = require('./utils');
|
|
5
|
-
const is = require('@axiosleo/cli-tool/src/helper/is');
|
|
6
5
|
|
|
7
6
|
function joinOn(table, on, options = {}) {
|
|
8
7
|
let o = _assign({ alias: null, join_type: 'INNER', table, on }, options);
|
|
@@ -24,6 +23,7 @@ class Query {
|
|
|
24
23
|
conditions: [],
|
|
25
24
|
orders: [],
|
|
26
25
|
tables: [],
|
|
26
|
+
attrs: [],
|
|
27
27
|
operator,
|
|
28
28
|
data: null,
|
|
29
29
|
groupField: [],
|
|
@@ -124,18 +124,12 @@ class Query {
|
|
|
124
124
|
return this;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
attr(...
|
|
128
|
-
if (
|
|
129
|
-
this.options.attrs = attr;
|
|
130
|
-
return this;
|
|
131
|
-
}
|
|
132
|
-
if (!attr.length) {
|
|
133
|
-
return this;
|
|
134
|
-
}
|
|
135
|
-
if (!this.options.attrs) {
|
|
127
|
+
attr(...attrs) {
|
|
128
|
+
if (!attrs.length) {
|
|
136
129
|
this.options.attrs = [];
|
|
130
|
+
return this;
|
|
137
131
|
}
|
|
138
|
-
this.options.attrs
|
|
132
|
+
this.options.attrs = attrs;
|
|
139
133
|
return this;
|
|
140
134
|
}
|
|
141
135
|
|