@axiosleo/orm-mysql 0.11.2 → 0.11.5
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/commands/generate.js +1 -1
- package/index.d.ts +27 -14
- package/package.json +2 -2
- package/src/builder.js +4 -4
- package/src/migration.js +1 -1
package/bin/orm-mysql.js
CHANGED
package/commands/generate.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -229,35 +229,48 @@ export declare class QueryOperator extends Query {
|
|
|
229
229
|
|
|
230
230
|
explain(operator: OperatorType): Promise<ExplainResult[]>;
|
|
231
231
|
|
|
232
|
-
select<T>(...attrs: string[]): Promise<T[]
|
|
232
|
+
select<T extends Object>(...attrs: string[]): Promise<T[]>;
|
|
233
|
+
select<T extends Object>(...attrs: string[]): Promise<Builder>;
|
|
233
234
|
|
|
234
|
-
find<T>(): Promise<T
|
|
235
|
+
find<T extends Object>(): Promise<T>;
|
|
236
|
+
find<T extends Object>(): Promise<Builder>;
|
|
235
237
|
|
|
236
|
-
count(): Promise<number
|
|
238
|
+
count(): Promise<number>;
|
|
239
|
+
count(): Promise<Builder>;
|
|
237
240
|
|
|
238
241
|
/**
|
|
239
242
|
* increment a column value
|
|
240
243
|
* @param attr
|
|
241
244
|
* @param increment default is 1
|
|
242
245
|
*/
|
|
243
|
-
incrBy(attr: string, increment?: string | number | ((number: number) => number)): Promise<MySQLQueryResult
|
|
246
|
+
incrBy(attr: string, increment?: string | number | ((number: number) => number)): Promise<MySQLQueryResult>;
|
|
247
|
+
incrBy(attr: string, increment?: string | number | ((number: number) => number)): Promise<Builder>;
|
|
244
248
|
|
|
245
|
-
delete(id?: number, index_field_name?: string): Promise<MySQLQueryResult
|
|
249
|
+
delete(id?: number, index_field_name?: string): Promise<MySQLQueryResult>;
|
|
250
|
+
delete(id?: number, index_field_name?: string): Promise<Builder>;
|
|
246
251
|
|
|
247
|
-
update(row?: any): Promise<MySQLQueryResult
|
|
252
|
+
update(row?: any): Promise<MySQLQueryResult>;
|
|
253
|
+
update(row?: any): Promise<Builder>;
|
|
248
254
|
|
|
249
|
-
update<T extends Object>(row?: T): Promise<MySQLQueryResult
|
|
255
|
+
update<T extends Object>(row?: T): Promise<MySQLQueryResult>;
|
|
256
|
+
update<T extends Object>(row?: T): Promise<Builder>;
|
|
250
257
|
|
|
251
|
-
insert(row?: any): Promise<MySQLQueryResult
|
|
258
|
+
insert(row?: any): Promise<MySQLQueryResult>;
|
|
259
|
+
insert(row?: any): Promise<Builder>;
|
|
252
260
|
|
|
253
|
-
insert<T extends Object>(row?: T): Promise<MySQLQueryResult
|
|
261
|
+
insert<T extends Object>(row?: T): Promise<MySQLQueryResult>;
|
|
262
|
+
insert<T extends Object>(row?: T): Promise<Builder>;
|
|
254
263
|
|
|
255
|
-
insertAll(rows: any[]): Promise<MySQLQueryResult[]
|
|
264
|
+
insertAll(rows: any[]): Promise<MySQLQueryResult[]>;
|
|
265
|
+
insertAll(rows: any[]): Promise<Builder>;
|
|
256
266
|
|
|
257
|
-
insertAll<T extends Object>(rows: T[]): Promise<MySQLQueryResult[]
|
|
267
|
+
insertAll<T extends Object>(rows: T[]): Promise<MySQLQueryResult[]>;
|
|
268
|
+
insertAll<T extends Object>(rows: T[]): Promise<Builder>;
|
|
258
269
|
|
|
259
|
-
upsertRow(row: any, condition: QueryCondition): Promise<MySQLQueryResult
|
|
270
|
+
upsertRow(row: any, condition: QueryCondition): Promise<MySQLQueryResult>;
|
|
271
|
+
upsertRow(row: any, condition: QueryCondition): Promise<Builder>;
|
|
260
272
|
|
|
273
|
+
upsertRow<T extends Object>(row: T, ...conditions: WhereItem[]): Promise<MySQLQueryResult>;
|
|
261
274
|
upsertRow<T extends Object>(row: T, ...conditions: WhereItem[]): Promise<MySQLQueryResult | Builder>;
|
|
262
275
|
|
|
263
276
|
notExec(): this;
|
|
@@ -437,7 +450,7 @@ interface ColumnItem {
|
|
|
437
450
|
unsigned?: boolean,
|
|
438
451
|
allowNull?: boolean,
|
|
439
452
|
default?: string | number | boolean | null | 'timestamp',
|
|
440
|
-
onUpdate?:
|
|
453
|
+
onUpdate?: string,
|
|
441
454
|
comment?: string,
|
|
442
455
|
autoIncrement?: boolean,
|
|
443
456
|
primaryKey?: boolean,
|
|
@@ -490,7 +503,7 @@ export declare class MigrationInterface {
|
|
|
490
503
|
unsigned?: boolean,
|
|
491
504
|
allowNull?: boolean,
|
|
492
505
|
default?: string | number | boolean | null | 'timestamp',
|
|
493
|
-
onUpdate?:
|
|
506
|
+
onUpdate?: string,
|
|
494
507
|
comment?: string,
|
|
495
508
|
autoIncrement?: boolean,
|
|
496
509
|
primaryKey?: boolean,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axiosleo/orm-mysql",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
4
|
"description": "MySQL ORM tool",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mysql",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"url": "https://github.com/AxiosLeo/node-orm-mysql"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/node": "^20.11.
|
|
38
|
+
"@types/node": "^20.11.46",
|
|
39
39
|
"chai": "^5.0.3",
|
|
40
40
|
"eslint": "^8.56.0",
|
|
41
41
|
"expect.js": "^0.3.1",
|
package/src/builder.js
CHANGED
|
@@ -680,7 +680,7 @@ class ManageSQLBuilder extends Builder {
|
|
|
680
680
|
} else if (type === 'TINYINT') {
|
|
681
681
|
str += '(4)';
|
|
682
682
|
}
|
|
683
|
-
if (options.allowNull === false) {
|
|
683
|
+
if (options.allowNull === false || options.primaryKey === true) {
|
|
684
684
|
str += ' NOT NULL';
|
|
685
685
|
}
|
|
686
686
|
if (options.unsigned === true) {
|
|
@@ -705,12 +705,12 @@ class ManageSQLBuilder extends Builder {
|
|
|
705
705
|
if (options.onUpdate) {
|
|
706
706
|
str += ` ON UPDATE ${options.onUpdate}`;
|
|
707
707
|
}
|
|
708
|
-
if (is.string(options.comment) && is.empty(options.comment) === false) {
|
|
709
|
-
str += ` COMMENT '${options.comment}'`;
|
|
710
|
-
}
|
|
711
708
|
if (options.autoIncrement === true) {
|
|
712
709
|
str += ' AUTO_INCREMENT';
|
|
713
710
|
}
|
|
711
|
+
if (is.string(options.comment) && is.empty(options.comment) === false) {
|
|
712
|
+
str += ` COMMENT '${options.comment}'`;
|
|
713
|
+
}
|
|
714
714
|
if (options.after) {
|
|
715
715
|
str += ' AFTER `' + options.after + '`';
|
|
716
716
|
}
|
package/src/migration.js
CHANGED
|
@@ -52,7 +52,7 @@ async function init(context) {
|
|
|
52
52
|
files = files.reverse();
|
|
53
53
|
}
|
|
54
54
|
context.files = files.filter(f => f !== '.connect.js');
|
|
55
|
-
|
|
55
|
+
context.config.dir = path.resolve(context.config.dir);
|
|
56
56
|
const connectPath = path.join(context.config.dir, '.connect.js');
|
|
57
57
|
if (await _exists(connectPath)) {
|
|
58
58
|
const connect = require(connectPath);
|