@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 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.9.8',
12
+ version: '0.9.9',
13
13
  commands_dir: path.join(__dirname, '../commands'),
14
14
  });
15
15
 
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiosleo/orm-mysql",
3
- "version": "0.9.8",
3
+ "version": "0.9.9",
4
4
  "description": "MySQL ORM tool",
5
5
  "keywords": [
6
6
  "mysql",
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(...attr) {
128
- if (attr.length === 1 && is.array(attr)) {
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.push(...attr);
132
+ this.options.attrs = attrs;
139
133
  return this;
140
134
  }
141
135