tspace-mysql 1.1.2 → 1.1.3
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/dist/cli/index.js +23 -24
- package/dist/cli/migrate/make.js +18 -41
- package/dist/cli/models/make.js +18 -18
- package/dist/cli/models/model.js +27 -2
- package/dist/cli/tables/make.js +10 -10
- package/dist/cli/tables/table.js +22 -2
- package/dist/lib/config/env.d.ts +6 -0
- package/dist/lib/config/env.js +16 -10
- package/dist/lib/connection/index.d.ts +29 -8
- package/dist/lib/connection/index.js +111 -55
- package/dist/lib/constants/index.js +7 -5
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/tspace/AbstractDB.js +3 -23
- package/dist/lib/tspace/AbstractDatabase.d.ts +9 -4
- package/dist/lib/tspace/AbstractDatabase.js +28 -31
- package/dist/lib/tspace/AbstractModel.d.ts +30 -16
- package/dist/lib/tspace/AbstractModel.js +3 -23
- package/dist/lib/tspace/Blueprint.d.ts +92 -21
- package/dist/lib/tspace/Blueprint.js +171 -140
- package/dist/lib/tspace/DB.d.ts +27 -4
- package/dist/lib/tspace/DB.js +66 -158
- package/dist/lib/tspace/Database.d.ts +100 -51
- package/dist/lib/tspace/Database.js +1335 -1911
- package/dist/lib/tspace/Interface.d.ts +8 -8
- package/dist/lib/tspace/Logger.js +19 -19
- package/dist/lib/tspace/Model.d.ts +168 -132
- package/dist/lib/tspace/Model.js +1467 -2081
- package/dist/lib/tspace/ProxyHandler.js +15 -26
- package/dist/lib/tspace/Schema.js +25 -117
- package/dist/lib/tspace/index.js +4 -4
- package/dist/lib/utils/index.d.ts +4 -3
- package/dist/lib/utils/index.js +87 -112
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import AbstractDatabase from './AbstractDatabase';
|
|
2
|
-
import {
|
|
2
|
+
import { Connection, ConnectionTransaction } from '../connection';
|
|
3
|
+
import { Pagination, Backup, ConnectionOptions, BackupToFile } from './Interface';
|
|
3
4
|
declare class Database extends AbstractDatabase {
|
|
4
5
|
constructor();
|
|
5
6
|
/**
|
|
@@ -13,13 +14,13 @@ declare class Database extends AbstractDatabase {
|
|
|
13
14
|
* @param {...string} columns
|
|
14
15
|
* @return {this} this
|
|
15
16
|
*/
|
|
16
|
-
except(...columns: string
|
|
17
|
+
except(...columns: Array<string>): this;
|
|
17
18
|
/**
|
|
18
19
|
*
|
|
19
20
|
* @param {...string} columns show only colums selected
|
|
20
21
|
* @return {this} this
|
|
21
22
|
*/
|
|
22
|
-
only(...columns: string
|
|
23
|
+
only(...columns: Array<string>): this;
|
|
23
24
|
/**
|
|
24
25
|
*
|
|
25
26
|
* @param {string=} column [column=id]
|
|
@@ -28,10 +29,10 @@ declare class Database extends AbstractDatabase {
|
|
|
28
29
|
distinct(column?: string): this;
|
|
29
30
|
/**
|
|
30
31
|
*
|
|
31
|
-
* @param {string
|
|
32
|
+
* @param {Array<string>} ...columns
|
|
32
33
|
* @return {this} this
|
|
33
34
|
*/
|
|
34
|
-
select(...columns: string
|
|
35
|
+
select(...columns: Array<string>): this;
|
|
35
36
|
/**
|
|
36
37
|
*
|
|
37
38
|
* @param {number} chunk
|
|
@@ -62,10 +63,30 @@ declare class Database extends AbstractDatabase {
|
|
|
62
63
|
orWhere(column: string, operator?: any, value?: any): this;
|
|
63
64
|
/**
|
|
64
65
|
*
|
|
65
|
-
* @param {string}
|
|
66
|
+
* @param {string} sql where column with raw sql
|
|
66
67
|
* @return {this} this
|
|
67
68
|
*/
|
|
68
69
|
whereRaw(sql: string): this;
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @param {string} query where column with raw sql
|
|
73
|
+
* @return {this} this
|
|
74
|
+
*/
|
|
75
|
+
orWhereRaw(sql: string): this;
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* @param {string} tableAndLocalKey
|
|
79
|
+
* @param {string?} tableAndForeignKey
|
|
80
|
+
* @return {this}
|
|
81
|
+
*/
|
|
82
|
+
whereReference(tableAndLocalKey: string, tableAndForeignKey?: any): this;
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* where exists
|
|
86
|
+
* @param {string} sql
|
|
87
|
+
* @return {this}
|
|
88
|
+
*/
|
|
89
|
+
whereExists(sql: string): this;
|
|
69
90
|
/**
|
|
70
91
|
*
|
|
71
92
|
* @param {number} id
|
|
@@ -156,37 +177,18 @@ declare class Database extends AbstractDatabase {
|
|
|
156
177
|
*/
|
|
157
178
|
whereSensitive(column: string, operator?: any, value?: any): this;
|
|
158
179
|
/**
|
|
159
|
-
* where
|
|
160
|
-
* @param {
|
|
161
|
-
* @param {string?} operator = < > != !< !>
|
|
162
|
-
* @param {any?} value
|
|
163
|
-
* @return {this}
|
|
164
|
-
*/
|
|
165
|
-
whereGroupStart(column: string, operator?: any, value?: any): this;
|
|
166
|
-
/**
|
|
167
|
-
* or where grouping of start statements
|
|
168
|
-
* @param {string} column
|
|
169
|
-
* @param {string?} operator = < > != !< !>
|
|
170
|
-
* @param {any?} value
|
|
180
|
+
* where group query
|
|
181
|
+
* @param {function} callback callback query
|
|
171
182
|
* @return {this}
|
|
172
183
|
*/
|
|
173
|
-
|
|
184
|
+
whereQuery(callback: Function): this;
|
|
174
185
|
/**
|
|
175
|
-
*
|
|
176
|
-
* @param {
|
|
177
|
-
* @param {string
|
|
178
|
-
* @param {any?} value
|
|
179
|
-
* @return {this}
|
|
180
|
-
*/
|
|
181
|
-
whereGroupEnd(column: string, operator?: any, value?: any): this;
|
|
182
|
-
/**
|
|
183
|
-
* where grouping of end statements
|
|
184
|
-
* @param {string} column
|
|
185
|
-
* @param {string?} operator = < > != !< !>
|
|
186
|
-
* @param {any?} value
|
|
186
|
+
* select by cases
|
|
187
|
+
* @param {array} cases array object [{ when : 'id < 7' , then : 'id is than under 7'}]
|
|
188
|
+
* @param {string} as
|
|
187
189
|
* @return {this}
|
|
188
190
|
*/
|
|
189
|
-
|
|
191
|
+
case(cases: string | any[], as: string): this;
|
|
190
192
|
/**
|
|
191
193
|
*
|
|
192
194
|
* @param {string} condition
|
|
@@ -224,25 +226,25 @@ declare class Database extends AbstractDatabase {
|
|
|
224
226
|
/**
|
|
225
227
|
*
|
|
226
228
|
* @param {string} column
|
|
227
|
-
* @param {string
|
|
229
|
+
* @param {string?} order [order=asc] asc, desc
|
|
228
230
|
* @return {this}
|
|
229
231
|
*/
|
|
230
232
|
orderBy(column: string, order?: string | undefined): this;
|
|
231
233
|
/**
|
|
232
234
|
*
|
|
233
|
-
* @param {string
|
|
235
|
+
* @param {string?} column [column=id]
|
|
234
236
|
* @return {this}
|
|
235
237
|
*/
|
|
236
238
|
latest(column?: string): this;
|
|
237
239
|
/**
|
|
238
240
|
*
|
|
239
|
-
* @param {string
|
|
241
|
+
* @param {string?} column [column=id]
|
|
240
242
|
* @return {this}
|
|
241
243
|
*/
|
|
242
244
|
oldest(column?: string): this;
|
|
243
245
|
/**
|
|
244
246
|
*
|
|
245
|
-
* @param {string
|
|
247
|
+
* @param {string?} column [column=id]
|
|
246
248
|
* @return {this}
|
|
247
249
|
*/
|
|
248
250
|
groupBy(column?: string): this;
|
|
@@ -257,13 +259,13 @@ declare class Database extends AbstractDatabase {
|
|
|
257
259
|
* @param {number=} number [number=1]
|
|
258
260
|
* @return {this}
|
|
259
261
|
*/
|
|
260
|
-
offset(number?: number): this;
|
|
262
|
+
offset(number?: number | undefined): this;
|
|
261
263
|
/**
|
|
262
264
|
*
|
|
263
265
|
* @param {...string} columns
|
|
264
266
|
* @return {this} this
|
|
265
267
|
*/
|
|
266
|
-
hidden(...columns: string
|
|
268
|
+
hidden(...columns: Array<string>): this;
|
|
267
269
|
/**
|
|
268
270
|
*
|
|
269
271
|
* update data in the database
|
|
@@ -372,6 +374,18 @@ declare class Database extends AbstractDatabase {
|
|
|
372
374
|
* @return {this} this
|
|
373
375
|
*/
|
|
374
376
|
connection(options: ConnectionOptions): this;
|
|
377
|
+
/**
|
|
378
|
+
*
|
|
379
|
+
* @param {Function} pool pool connection database
|
|
380
|
+
* @return {this} this
|
|
381
|
+
*/
|
|
382
|
+
pool(pool: Connection): this;
|
|
383
|
+
/**
|
|
384
|
+
*
|
|
385
|
+
* @param {object} connection pool database
|
|
386
|
+
* @return {this} this
|
|
387
|
+
*/
|
|
388
|
+
bind(connection: Connection | ConnectionTransaction): this;
|
|
375
389
|
/**
|
|
376
390
|
* execute sql statements with raw sql query
|
|
377
391
|
* @param {string} sql sql execute return data
|
|
@@ -440,12 +454,32 @@ declare class Database extends AbstractDatabase {
|
|
|
440
454
|
} | null>;
|
|
441
455
|
/**
|
|
442
456
|
*
|
|
443
|
-
* execute data return object |
|
|
457
|
+
* execute data return object | throw rror
|
|
444
458
|
* @return {promise<object | null>}
|
|
445
459
|
*/
|
|
446
460
|
findOne(): Promise<{
|
|
447
461
|
[key: string]: any;
|
|
448
462
|
} | null>;
|
|
463
|
+
/**
|
|
464
|
+
*
|
|
465
|
+
* execute data return object | throw Error
|
|
466
|
+
* @return {promise<object | Error>}
|
|
467
|
+
*/
|
|
468
|
+
firstOrError(message: string, options?: {
|
|
469
|
+
[key: string]: any;
|
|
470
|
+
}): Promise<{
|
|
471
|
+
[key: string]: any;
|
|
472
|
+
}>;
|
|
473
|
+
/**
|
|
474
|
+
*
|
|
475
|
+
* execute data return object | null
|
|
476
|
+
* @return {promise<object | null>}
|
|
477
|
+
*/
|
|
478
|
+
findOneOrError(message: string, options?: {
|
|
479
|
+
[key: string]: any;
|
|
480
|
+
}): Promise<{
|
|
481
|
+
[key: string]: any;
|
|
482
|
+
}>;
|
|
449
483
|
/**
|
|
450
484
|
*
|
|
451
485
|
* execute data return Array
|
|
@@ -540,10 +574,9 @@ declare class Database extends AbstractDatabase {
|
|
|
540
574
|
findManyGroupBy(column: string): Promise<Array<any>>;
|
|
541
575
|
/**
|
|
542
576
|
* execute data when save *action [insert , update]
|
|
543
|
-
* @param {object} transaction | DB.beginTransaction()
|
|
544
577
|
* @return {Promise<any>}
|
|
545
578
|
*/
|
|
546
|
-
save(
|
|
579
|
+
save(): Promise<any>;
|
|
547
580
|
/**
|
|
548
581
|
*
|
|
549
582
|
* show columns in table
|
|
@@ -554,7 +587,7 @@ declare class Database extends AbstractDatabase {
|
|
|
554
587
|
/**
|
|
555
588
|
*
|
|
556
589
|
* show schemas in table
|
|
557
|
-
* @param {string=} table table name
|
|
590
|
+
* @param {string=} table [table= current table name]
|
|
558
591
|
* @return {Promise<Array>}
|
|
559
592
|
*/
|
|
560
593
|
showSchemas(table?: string): Promise<Array<string>>;
|
|
@@ -567,20 +600,35 @@ declare class Database extends AbstractDatabase {
|
|
|
567
600
|
showValues(table?: string): Promise<Array<string>>;
|
|
568
601
|
/**
|
|
569
602
|
*
|
|
570
|
-
* backup database intro new database same server or to another server
|
|
603
|
+
* backup this database intro new database same server or to another server
|
|
571
604
|
* @param {Object} backupOptions
|
|
572
605
|
* @param {string} backup.database
|
|
606
|
+
* @param {object?} backup.to
|
|
607
|
+
* @param {string} backup.to.host
|
|
608
|
+
* @param {number} backup.to.port
|
|
609
|
+
* @param {string} backup.to.database
|
|
610
|
+
* @param {string} backup.to.username
|
|
611
|
+
* @param {string} backup.to.password
|
|
612
|
+
|
|
613
|
+
* @return {Promise<boolean>}
|
|
614
|
+
*/
|
|
615
|
+
backup({ database, to }: Backup): Promise<boolean>;
|
|
616
|
+
/**
|
|
617
|
+
*
|
|
618
|
+
* backup database intro file
|
|
619
|
+
* @param {Object} backupOptions
|
|
620
|
+
* @param {string} backup.database
|
|
621
|
+
* @param {object?} backup.filePath
|
|
573
622
|
* @param {object?} backup.connection
|
|
574
|
-
* @param {string}
|
|
575
|
-
* @param {number}
|
|
576
|
-
* @param {string}
|
|
577
|
-
* @param {string}
|
|
578
|
-
* @param {string}
|
|
623
|
+
* @param {string} backup.connection.host
|
|
624
|
+
* @param {number} backup.connection.port
|
|
625
|
+
* @param {string} backup.connection.database
|
|
626
|
+
* @param {string} backup.connection.username
|
|
627
|
+
* @param {string} backup.connection.password
|
|
579
628
|
|
|
580
629
|
* @return {Promise<boolean>}
|
|
581
630
|
*/
|
|
582
|
-
|
|
583
|
-
backupToFile({ filePath, database, connection }: BackupToFile): Promise<boolean>;
|
|
631
|
+
backupToFile({ filePath, database, connection }: BackupToFile): Promise<void>;
|
|
584
632
|
/**
|
|
585
633
|
*
|
|
586
634
|
* fake data
|
|
@@ -601,6 +649,7 @@ declare class Database extends AbstractDatabase {
|
|
|
601
649
|
*/
|
|
602
650
|
drop(): Promise<boolean>;
|
|
603
651
|
private _queryWhereIsExists;
|
|
652
|
+
private _bindTableAndColumnInQueryWhere;
|
|
604
653
|
private _insertNotExists;
|
|
605
654
|
private _setupPool;
|
|
606
655
|
private _queryStatement;
|
|
@@ -615,7 +664,7 @@ declare class Database extends AbstractDatabase {
|
|
|
615
664
|
private _queryInsertMultiple;
|
|
616
665
|
private _valueAndOperator;
|
|
617
666
|
private _valueTrueFalse;
|
|
618
|
-
private
|
|
667
|
+
private _buildQuery;
|
|
619
668
|
private _setupLogger;
|
|
620
669
|
private _initialConnection;
|
|
621
670
|
}
|