tspace-mysql 1.9.4-beta.2 → 1.9.4-beta.4
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/README.md +310 -52
- package/dist/cli/dump/db.js +3 -15
- package/dist/cli/dump/db.js.map +1 -1
- package/dist/cli/index.js +0 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/migrations/make-db.js +1 -1
- package/dist/cli/migrations/make-db.js.map +1 -1
- package/dist/cli/migrations/make-model.js +1 -6
- package/dist/cli/migrations/make-model.js.map +1 -1
- package/dist/lib/config/index.d.ts +2 -2
- package/dist/lib/config/index.js +14 -5
- package/dist/lib/config/index.js.map +1 -1
- package/dist/lib/constants/index.d.ts +1 -0
- package/dist/lib/constants/index.js +1 -0
- package/dist/lib/constants/index.js.map +1 -1
- package/dist/lib/core/Abstracts/AbstractBuilder.d.ts +2 -1
- package/dist/lib/core/Abstracts/AbstractDB.d.ts +5 -3
- package/dist/lib/core/Abstracts/AbstractDB.js.map +1 -1
- package/dist/lib/core/Blueprint.d.ts +10 -0
- package/dist/lib/core/Blueprint.js +15 -0
- package/dist/lib/core/Blueprint.js.map +1 -1
- package/dist/lib/core/Builder.d.ts +145 -10
- package/dist/lib/core/Builder.js +499 -143
- package/dist/lib/core/Builder.js.map +1 -1
- package/dist/lib/core/DB.d.ts +130 -196
- package/dist/lib/core/DB.js +434 -529
- package/dist/lib/core/DB.js.map +1 -1
- package/dist/lib/core/Driver/index.d.ts +15 -1
- package/dist/lib/core/Driver/index.js +3 -0
- package/dist/lib/core/Driver/index.js.map +1 -1
- package/dist/lib/core/Driver/mariadb/MariadbQueryBuilder.d.ts +14 -0
- package/dist/lib/core/Driver/mariadb/MariadbQueryBuilder.js +135 -33
- package/dist/lib/core/Driver/mariadb/MariadbQueryBuilder.js.map +1 -1
- package/dist/lib/core/Driver/mongodb/MongodbQueryBuilder.d.ts +14 -0
- package/dist/lib/core/Driver/mongodb/MongodbQueryBuilder.js +28 -0
- package/dist/lib/core/Driver/mongodb/MongodbQueryBuilder.js.map +1 -1
- package/dist/lib/core/Driver/mysql/MysqlQueryBuilder.d.ts +14 -0
- package/dist/lib/core/Driver/mysql/MysqlQueryBuilder.js +105 -23
- package/dist/lib/core/Driver/mysql/MysqlQueryBuilder.js.map +1 -1
- package/dist/lib/core/Driver/postgres/PostgresQueryBuilder.d.ts +16 -1
- package/dist/lib/core/Driver/postgres/PostgresQueryBuilder.js +238 -79
- package/dist/lib/core/Driver/postgres/PostgresQueryBuilder.js.map +1 -1
- package/dist/lib/core/Driver/sqlite/SqliteDriver.js +1 -1
- package/dist/lib/core/Driver/sqlite/SqliteDriver.js.map +1 -1
- package/dist/lib/core/Driver/sqlite/SqliteQueryBuilder.d.ts +17 -0
- package/dist/lib/core/Driver/sqlite/SqliteQueryBuilder.js +148 -28
- package/dist/lib/core/Driver/sqlite/SqliteQueryBuilder.js.map +1 -1
- package/dist/lib/core/Model.d.ts +243 -33
- package/dist/lib/core/Model.js +354 -56
- package/dist/lib/core/Model.js.map +1 -1
- package/dist/lib/core/Package.d.ts +5 -0
- package/dist/lib/core/Package.js +7 -2
- package/dist/lib/core/Package.js.map +1 -1
- package/dist/lib/core/Pool.js +44 -62
- package/dist/lib/core/Pool.js.map +1 -1
- package/dist/lib/core/Queue/types.d.ts +1 -0
- package/dist/lib/core/Queue/worker-lock.d.ts +17 -0
- package/dist/lib/core/Queue/worker-lock.js +30 -0
- package/dist/lib/core/Queue/worker-lock.js.map +1 -0
- package/dist/lib/core/Queue/worker.d.ts +6 -3
- package/dist/lib/core/Queue/worker.js +126 -46
- package/dist/lib/core/Queue/worker.js.map +1 -1
- package/dist/lib/core/Repository.d.ts +164 -29
- package/dist/lib/core/Repository.js +180 -40
- package/dist/lib/core/Repository.js.map +1 -1
- package/dist/lib/core/Schema.d.ts +5 -2
- package/dist/lib/core/Schema.js +111 -3
- package/dist/lib/core/Schema.js.map +1 -1
- package/dist/lib/core/StateManager.d.ts +17 -0
- package/dist/lib/core/StateManager.js +5 -1
- package/dist/lib/core/StateManager.js.map +1 -1
- package/dist/lib/core/UtilityTypes.d.ts +5 -1
- package/dist/lib/core/UtilityTypes.js.map +1 -1
- package/dist/lib/types/index.d.ts +56 -24
- package/dist/lib/types/repository/index.d.ts +10 -18
- package/dist/lib/utils/index.d.ts +6 -2
- package/dist/lib/utils/index.js +85 -15
- package/dist/lib/utils/index.js.map +1 -1
- package/package.json +1 -2
- package/dist/cli/dump/table.d.ts +0 -4
- package/dist/cli/dump/table.js +0 -41
- package/dist/cli/dump/table.js.map +0 -1
package/dist/lib/core/DB.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractDB } from "./Abstracts/AbstractDB";
|
|
2
|
-
import type { TConstant,
|
|
2
|
+
import type { TConstant, TClone, TDump, TPoolConnected, TConnectionOptions, TConnectionTransaction, TRawStringQuery, TFreezeStringQuery, TPoolEvent } from "../types";
|
|
3
3
|
/**
|
|
4
4
|
* The 'DB' class is a component of the database system
|
|
5
5
|
* @param {string?} table table name
|
|
@@ -168,45 +168,17 @@ declare class DB extends AbstractDB {
|
|
|
168
168
|
*/
|
|
169
169
|
static query<T = any>(sql: string, parameters?: (boolean | number | string | any[] | null)[] | Record<string, any>): Promise<T>;
|
|
170
170
|
/**
|
|
171
|
-
* The '
|
|
172
|
-
*
|
|
173
|
-
* @param {string} sql - The SQL statement to execute.
|
|
174
|
-
* @returns {AsyncGenerator<T>} An async generator that yields result rows.
|
|
175
|
-
*
|
|
176
|
-
* @example
|
|
177
|
-
* ```ts
|
|
178
|
-
* import { DB } from "tspace-mysql";
|
|
179
|
-
*
|
|
180
|
-
* for await (const row of DB.stream('SELECT * FROM users')) {
|
|
181
|
-
* console.log(row);
|
|
182
|
-
* }
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
stream<T = any>(sql: string, parameters?: (boolean | number | string | any[] | null)[] | Record<string, any>): AsyncGenerator<T>;
|
|
186
|
-
/**
|
|
187
|
-
* The 'stream' method is used to executes a SQL statement and asynchronously yields result rows.
|
|
171
|
+
* The 'from' method is used to define the from table name.
|
|
188
172
|
*
|
|
189
173
|
* @static
|
|
190
|
-
* @param {string} sql - The SQL statement to execute.
|
|
191
|
-
* @returns {AsyncGenerator<T>} An async generator that yields result rows.
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```ts
|
|
195
|
-
* import { DB } from "tspace-mysql";
|
|
196
|
-
*
|
|
197
|
-
* for await (const row of DB.stream('SELECT * FROM users')) {
|
|
198
|
-
* console.log(row);
|
|
199
|
-
* }
|
|
200
|
-
*/
|
|
201
|
-
static stream<T = any>(sql: string, parameters?: (boolean | number | string | any[] | null)[] | Record<string, any>): AsyncGenerator<T>;
|
|
202
|
-
/**
|
|
203
|
-
* The 'from' method is used to define the from table name.
|
|
204
174
|
* @param {string} table table name
|
|
205
175
|
* @returns {this} this
|
|
206
176
|
*/
|
|
207
177
|
static from(table: string): DB;
|
|
208
178
|
/**
|
|
209
179
|
* The 'table' method is used to define the table name.
|
|
180
|
+
*
|
|
181
|
+
* @static
|
|
210
182
|
* @param {string} table table name
|
|
211
183
|
* @returns {DB} DB
|
|
212
184
|
*/
|
|
@@ -214,11 +186,19 @@ declare class DB extends AbstractDB {
|
|
|
214
186
|
/**
|
|
215
187
|
* The 'alias' method is used to set the table name.
|
|
216
188
|
*
|
|
189
|
+
* @static
|
|
217
190
|
* @param {string} sql raw sql from make a new alias for this table
|
|
218
191
|
* @param {string} alias alias name
|
|
219
192
|
* @returns {DB} DB
|
|
220
193
|
*/
|
|
221
194
|
static alias(sql: string, alias: string): DB;
|
|
195
|
+
/**
|
|
196
|
+
*
|
|
197
|
+
* @static
|
|
198
|
+
* @override
|
|
199
|
+
* @returns {this} this
|
|
200
|
+
*/
|
|
201
|
+
static dd(): DB;
|
|
222
202
|
/**
|
|
223
203
|
* The 'jsonObject' method is used to specify select data to JSON objects.
|
|
224
204
|
* @param {string} object table name
|
|
@@ -228,6 +208,7 @@ declare class DB extends AbstractDB {
|
|
|
228
208
|
jsonObject(object: Record<string, string>, alias: string): string;
|
|
229
209
|
/**
|
|
230
210
|
* The 'jsonObject' method is used to specify select data to JSON objects.
|
|
211
|
+
*
|
|
231
212
|
* @static
|
|
232
213
|
* @param {string} object table name
|
|
233
214
|
* @param {string} alias
|
|
@@ -236,6 +217,7 @@ declare class DB extends AbstractDB {
|
|
|
236
217
|
static jsonObject(object: Record<string, string>, alias: string): string;
|
|
237
218
|
/**
|
|
238
219
|
* The 'JSONObject' method is used to specify select data to JSON objects.
|
|
220
|
+
*
|
|
239
221
|
* @param {string} object table name
|
|
240
222
|
* @param {string} alias
|
|
241
223
|
* @returns {string} string
|
|
@@ -243,6 +225,7 @@ declare class DB extends AbstractDB {
|
|
|
243
225
|
JSONObject(object: Record<string, string>, alias: string): string;
|
|
244
226
|
/**
|
|
245
227
|
* The 'JSONObject' method is used to specify select data to JSON objects.
|
|
228
|
+
*
|
|
246
229
|
* @static
|
|
247
230
|
* @param {string} object table name
|
|
248
231
|
* @param {string} alias
|
|
@@ -257,6 +240,7 @@ declare class DB extends AbstractDB {
|
|
|
257
240
|
constants(key?: keyof TConstant): string | object;
|
|
258
241
|
/**
|
|
259
242
|
* The 'constants' method is used to return constants with key or none in 'DB' or 'Model'.
|
|
243
|
+
*
|
|
260
244
|
* @static
|
|
261
245
|
* @param {string} key
|
|
262
246
|
* @returns {string | object} string || object
|
|
@@ -274,6 +258,7 @@ declare class DB extends AbstractDB {
|
|
|
274
258
|
}[], final?: string): string | [];
|
|
275
259
|
/**
|
|
276
260
|
* select by cases
|
|
261
|
+
*
|
|
277
262
|
* @static
|
|
278
263
|
* @param {arrayObject} cases array object {when , then }
|
|
279
264
|
* @param {string?} final else condition
|
|
@@ -284,16 +269,26 @@ declare class DB extends AbstractDB {
|
|
|
284
269
|
then: string;
|
|
285
270
|
}[], final?: string): string | [];
|
|
286
271
|
/**
|
|
287
|
-
* The 'generateUUID' methid is used to generate a universal unique identifier.
|
|
272
|
+
* The 'generateUUID' methid is used to generate a universal unique identifier (UUID).
|
|
273
|
+
*
|
|
274
|
+
* @param options - Options for UUID generation.
|
|
275
|
+
* @param options.v - UUID version to generate: 4 (random) or 7 (time-ordered). Defaults to 7.
|
|
288
276
|
* @returns {string} string
|
|
289
277
|
*/
|
|
290
|
-
generateUUID(
|
|
278
|
+
generateUUID({ v }?: {
|
|
279
|
+
v?: 4 | 7;
|
|
280
|
+
}): string;
|
|
291
281
|
/**
|
|
292
|
-
* The 'generateUUID' methid is used to generate a universal unique identifier.
|
|
282
|
+
* The 'generateUUID' methid is used to generate a universal unique identifier (UUID).
|
|
283
|
+
*
|
|
284
|
+
* @param options - Options for UUID generation.
|
|
285
|
+
* @param options.v - UUID version to generate: 4 (random) or 7 (time-ordered). Defaults to 7.
|
|
293
286
|
* @static
|
|
294
287
|
* @returns {string} string
|
|
295
288
|
*/
|
|
296
|
-
static generateUUID(
|
|
289
|
+
static generateUUID({ v }?: {
|
|
290
|
+
v?: 4 | 7;
|
|
291
|
+
}): string;
|
|
297
292
|
/**
|
|
298
293
|
* The 'snakeCase' methid is used to covert value to snakeCase pattern.
|
|
299
294
|
* @returns {string} string
|
|
@@ -321,6 +316,8 @@ declare class DB extends AbstractDB {
|
|
|
321
316
|
escape(value: string): string;
|
|
322
317
|
/**
|
|
323
318
|
* The 'escape' methid is used to escaping SQL injections.
|
|
319
|
+
*
|
|
320
|
+
* @static
|
|
324
321
|
* @returns {string} string
|
|
325
322
|
*/
|
|
326
323
|
static escape(value: string): string;
|
|
@@ -331,6 +328,8 @@ declare class DB extends AbstractDB {
|
|
|
331
328
|
escapeXSS(value: string): string;
|
|
332
329
|
/**
|
|
333
330
|
* The 'escapeXSS' methid is used to escaping XSS characters.
|
|
331
|
+
*
|
|
332
|
+
* @static
|
|
334
333
|
* @returns {string} string
|
|
335
334
|
*/
|
|
336
335
|
static escapeXSS(value: string): string;
|
|
@@ -425,9 +424,6 @@ declare class DB extends AbstractDB {
|
|
|
425
424
|
*
|
|
426
425
|
* Transactions are typically used when you want to ensure that a series of database operations either all succeed or all fail together,
|
|
427
426
|
* ensuring data integrity.
|
|
428
|
-
* @param {object} options
|
|
429
|
-
* @property {number | undefined} options.primaryId
|
|
430
|
-
* @property {number | undefined} options.nodeId
|
|
431
427
|
* @returns {ConnectionTransaction} object - Connection for the transaction
|
|
432
428
|
* @type {object} connection
|
|
433
429
|
* @property {function} connection.query - execute query sql then release connection to pool
|
|
@@ -435,10 +431,7 @@ declare class DB extends AbstractDB {
|
|
|
435
431
|
* @property {function} connection.commit - commit transaction of query
|
|
436
432
|
* @property {function} connection.rollback - rollback transaction of query
|
|
437
433
|
*/
|
|
438
|
-
beginTransaction(
|
|
439
|
-
primaryId?: number;
|
|
440
|
-
nodeId?: number;
|
|
441
|
-
}): Promise<TConnectionTransaction>;
|
|
434
|
+
beginTransaction(): Promise<TConnectionTransaction>;
|
|
442
435
|
/**
|
|
443
436
|
* The 'beginTransaction' is a method used to initiate a database transaction within your application's code.
|
|
444
437
|
*
|
|
@@ -446,9 +439,6 @@ declare class DB extends AbstractDB {
|
|
|
446
439
|
*
|
|
447
440
|
* Transactions are typically used when you want to ensure that a series of database operations either all succeed or all fail together,
|
|
448
441
|
* ensuring data integrity.
|
|
449
|
-
* @param {object} options
|
|
450
|
-
* @property {number | undefined} options.primaryId
|
|
451
|
-
* @property {number | undefined} options.nodeId
|
|
452
442
|
* @static
|
|
453
443
|
* @returns {ConnectionTransaction} object - Connection for the transaction
|
|
454
444
|
* @type {object} connection
|
|
@@ -457,12 +447,9 @@ declare class DB extends AbstractDB {
|
|
|
457
447
|
* @property {function} connection.commit - commit transaction of query
|
|
458
448
|
* @property {function} connection.rollback - rollback transaction of query
|
|
459
449
|
*/
|
|
460
|
-
static beginTransaction(
|
|
461
|
-
primaryId?: number;
|
|
462
|
-
nodeId?: number;
|
|
463
|
-
}): Promise<TConnectionTransaction>;
|
|
450
|
+
static beginTransaction(): Promise<TConnectionTransaction>;
|
|
464
451
|
/**
|
|
465
|
-
* Execute a database transaction.
|
|
452
|
+
* The 'transaction' is a method used to Execute a database transaction.
|
|
466
453
|
*
|
|
467
454
|
* This method will:
|
|
468
455
|
* - Acquire a connection from the pool
|
|
@@ -472,15 +459,15 @@ declare class DB extends AbstractDB {
|
|
|
472
459
|
* - Rollback if any error occurs
|
|
473
460
|
*
|
|
474
461
|
* @template T
|
|
475
|
-
* @param {(conn:
|
|
462
|
+
* @param {(conn: TConnectionTransaction) => Promise<T>} handler - Async function that receives the transaction connection.
|
|
476
463
|
* All queries inside this handler MUST use the provided `conn` instance.
|
|
477
464
|
*
|
|
478
465
|
* @returns {Promise<T>} The result returned from the handler.
|
|
479
466
|
*
|
|
480
467
|
*/
|
|
481
|
-
transaction<T>(handler: (conn:
|
|
468
|
+
transaction<T>(handler: (conn: TConnectionTransaction) => Promise<T>): Promise<T>;
|
|
482
469
|
/**
|
|
483
|
-
* Execute a database transaction.
|
|
470
|
+
* The 'transaction' is a method used to Execute a database transaction.
|
|
484
471
|
*
|
|
485
472
|
* This method will:
|
|
486
473
|
* - Acquire a connection from the pool
|
|
@@ -489,14 +476,15 @@ declare class DB extends AbstractDB {
|
|
|
489
476
|
* - Commit if successful
|
|
490
477
|
* - Rollback if any error occurs
|
|
491
478
|
*
|
|
479
|
+
* @static
|
|
492
480
|
* @template T
|
|
493
|
-
* @param {(conn:
|
|
481
|
+
* @param {(conn: TConnectionTransaction) => Promise<T>} handler - Async function that receives the transaction connection.
|
|
494
482
|
* All queries inside this handler MUST use the provided `conn` instance.
|
|
495
483
|
*
|
|
496
484
|
* @returns {Promise<T>} The result returned from the handler.
|
|
497
485
|
*
|
|
498
486
|
*/
|
|
499
|
-
static transaction<T>(handler: (conn:
|
|
487
|
+
static transaction<T>(handler: (conn: TConnectionTransaction) => Promise<T>): Promise<T>;
|
|
500
488
|
/**
|
|
501
489
|
* The 'getActiveConnections' method is used to return active connections
|
|
502
490
|
*
|
|
@@ -506,6 +494,7 @@ declare class DB extends AbstractDB {
|
|
|
506
494
|
/**
|
|
507
495
|
* The 'getActiveConnections' method is used to return active connections
|
|
508
496
|
*
|
|
497
|
+
* @static
|
|
509
498
|
* @returns {Promise<number>} this
|
|
510
499
|
*/
|
|
511
500
|
static getActiveConnections(): Promise<number>;
|
|
@@ -518,175 +507,120 @@ declare class DB extends AbstractDB {
|
|
|
518
507
|
/**
|
|
519
508
|
* The 'getMaxConnections' method is used to return max connections
|
|
520
509
|
*
|
|
510
|
+
* @static
|
|
521
511
|
* @returns {Promise<number>} this
|
|
522
512
|
*/
|
|
523
513
|
static getMaxConnections(): Promise<number>;
|
|
524
514
|
/**
|
|
525
|
-
*
|
|
515
|
+
* This'clone' method is used to clone the current database into a new database
|
|
516
|
+
* on the same server or another server.
|
|
526
517
|
*
|
|
527
|
-
* @
|
|
528
|
-
* @
|
|
529
|
-
* @
|
|
518
|
+
* @property {string} database - Target database name.
|
|
519
|
+
* @property {string[]} excludes - Tables to exclude from the clone.
|
|
520
|
+
* @property {object} to - Target server connection.
|
|
521
|
+
* @property {string} to.host - Target server host.
|
|
522
|
+
* @property {number} to.port - Target server port.
|
|
523
|
+
* @property {string} to.username - Target server username.
|
|
524
|
+
* @property {string} to.password - Target server password.
|
|
525
|
+
* @returns {Promise<void>}
|
|
530
526
|
*/
|
|
531
|
-
|
|
527
|
+
clone({ database, excludes, only, value, to }: TClone): Promise<void>;
|
|
532
528
|
/**
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
529
|
+
* This'clone' method is used to clone the current database into a new database
|
|
530
|
+
* on the same server or another server.
|
|
531
|
+
*
|
|
532
|
+
* @static
|
|
533
|
+
* @property {string} database - Target database name.
|
|
534
|
+
* @property {string[]} excludes - Tables to exclude from the clone.
|
|
535
|
+
* @property {object} to - Target server connection.
|
|
536
|
+
* @property {string} to.host - Target server host.
|
|
537
|
+
* @property {number} to.port - Target server port.
|
|
538
|
+
* @property {string} to.username - Target server username.
|
|
539
|
+
* @property {string} to.password - Target server password.
|
|
540
|
+
* @returns {Promise<void>}
|
|
541
|
+
*/
|
|
542
|
+
static clone({ database, only, excludes, value, to }: TClone): Promise<void>;
|
|
540
543
|
/**
|
|
541
544
|
*
|
|
542
|
-
* This '
|
|
543
|
-
* @type
|
|
544
|
-
* @property {string}
|
|
545
|
-
* @
|
|
546
|
-
* @property {string}
|
|
547
|
-
* @property {
|
|
548
|
-
* @property {string} backup.to.username
|
|
549
|
-
* @property {string} backup.to.password
|
|
545
|
+
* This 'dump' method is used to Dumps a database into a SQL file
|
|
546
|
+
* @type {Object} opt
|
|
547
|
+
* @property {string?} opt.database
|
|
548
|
+
* @property {string} opt.filePath
|
|
549
|
+
* @property {string[]} opt.excludes
|
|
550
|
+
* @property {boolean?} opt.value
|
|
550
551
|
* @returns {Promise<void>}
|
|
551
552
|
*/
|
|
552
|
-
|
|
553
|
+
dump({ filePath, excludes, only, database, value }: TDump): Promise<void>;
|
|
553
554
|
/**
|
|
555
|
+
* This 'dump' method is used to Dumps a database into a SQL file
|
|
554
556
|
*
|
|
555
|
-
*
|
|
556
|
-
* @type
|
|
557
|
-
* @property {string}
|
|
558
|
-
* @
|
|
559
|
-
* @property {string}
|
|
560
|
-
* @property {
|
|
561
|
-
* @property {string} backup.to.username
|
|
562
|
-
* @property {string} backup.to.password
|
|
557
|
+
* @static
|
|
558
|
+
* @type {Object} opt
|
|
559
|
+
* @property {string?} opt.database
|
|
560
|
+
* @property {string} opt.filePath
|
|
561
|
+
* @property {string[]} opt.excludes
|
|
562
|
+
* @property {boolean?} opt.value
|
|
563
563
|
* @returns {Promise<void>}
|
|
564
564
|
*/
|
|
565
|
-
static
|
|
565
|
+
static dump({ filePath, database, excludes, only, value, }: TDump): Promise<void>;
|
|
566
566
|
/**
|
|
567
|
+
* This 'session' method is used to manage database session variables.
|
|
567
568
|
*
|
|
568
|
-
*
|
|
569
|
-
*
|
|
570
|
-
* @property {string} backup.database
|
|
571
|
-
* @property {string} backup.filePath
|
|
572
|
-
* @type {object?} backup.connection
|
|
573
|
-
* @property {string} backup.connection.host
|
|
574
|
-
* @property {number} backup.connection.port
|
|
575
|
-
* @property {number} backup.connection.database
|
|
576
|
-
* @property {string} backup.connection.username
|
|
577
|
-
* @property {string} backup.connection.password
|
|
578
|
-
* @returns {Promise<void>}
|
|
579
|
-
*/
|
|
580
|
-
backupToFile({ filePath, database, connection, }: TBackupToFile): Promise<void>;
|
|
581
|
-
/**
|
|
569
|
+
* Provides methods to get and set session variables for the current
|
|
570
|
+
* database connection.
|
|
582
571
|
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
* @property {string} backup.connection.host
|
|
589
|
-
* @property {number} backup.connection.port
|
|
590
|
-
* @property {number} backup.connection.database
|
|
591
|
-
* @property {string} backup.connection.username
|
|
592
|
-
* @property {string} backup.connection.password
|
|
593
|
-
* @returns {Promise<void>}
|
|
594
|
-
*/
|
|
595
|
-
static backupToFile({ filePath, database, connection, }: TBackupToFile): Promise<void>;
|
|
596
|
-
/**
|
|
572
|
+
* Supported drivers:
|
|
573
|
+
* - MySQL
|
|
574
|
+
* - MariaDB
|
|
575
|
+
* - PostgreSQL
|
|
576
|
+
* - SQLite
|
|
597
577
|
*
|
|
598
|
-
*
|
|
599
|
-
* @type {Object} backup
|
|
600
|
-
* @property {string} backup.database
|
|
601
|
-
* @property {string} backup.filePath
|
|
602
|
-
* @type {object?} backup.connection
|
|
603
|
-
* @property {string} backup.connection.host
|
|
604
|
-
* @property {number} backup.connection.port
|
|
605
|
-
* @property {number} backup.connection.database
|
|
606
|
-
* @property {string} backup.connection.username
|
|
607
|
-
* @property {string} backup.connection.password
|
|
608
|
-
* @returns {Promise<void>}
|
|
609
|
-
*/
|
|
610
|
-
backupSchemaToFile({ filePath, database, connection, }: TBackupToFile): Promise<void>;
|
|
611
|
-
/**
|
|
578
|
+
* MongoDB is not supported.
|
|
612
579
|
*
|
|
613
|
-
*
|
|
580
|
+
* @example
|
|
581
|
+
* ```ts
|
|
582
|
+
* await DB.session().set('db', 'primary');
|
|
614
583
|
*
|
|
615
|
-
*
|
|
616
|
-
*
|
|
617
|
-
*
|
|
618
|
-
*
|
|
619
|
-
* @property {string} backup.connection.host
|
|
620
|
-
* @property {number} backup.connection.port
|
|
621
|
-
* @property {number} backup.connection.database
|
|
622
|
-
* @property {string} backup.connection.username
|
|
623
|
-
* @property {string} backup.connection.password
|
|
624
|
-
* @returns {Promise<void>}
|
|
584
|
+
* const value = await db.session().get('db');
|
|
585
|
+
* console.log(value) // primary
|
|
586
|
+
*
|
|
587
|
+
* ```
|
|
625
588
|
*/
|
|
626
|
-
|
|
589
|
+
session(): {
|
|
590
|
+
get(name: string): Promise<string | null>;
|
|
591
|
+
set(name: string, value: string): Promise<void>;
|
|
592
|
+
delete(name: string): Promise<void>;
|
|
593
|
+
};
|
|
627
594
|
/**
|
|
595
|
+
* This 'session' method is used to manage database session variables.
|
|
628
596
|
*
|
|
629
|
-
*
|
|
597
|
+
* Provides methods to get and set session variables for the current
|
|
598
|
+
* database connection.
|
|
630
599
|
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
*
|
|
636
|
-
* @property {number} backup.connection.port
|
|
637
|
-
* @property {number} backup.connection.database
|
|
638
|
-
* @property {string} backup.connection.username
|
|
639
|
-
* @property {string} backup.connection.password
|
|
640
|
-
* @returns {Promise<void>}
|
|
641
|
-
*/
|
|
642
|
-
backupTableToFile({ filePath, table, connection, }: TBackupTableToFile): Promise<void>;
|
|
643
|
-
/**
|
|
600
|
+
* Supported drivers:
|
|
601
|
+
* - MySQL
|
|
602
|
+
* - MariaDB
|
|
603
|
+
* - PostgreSQL
|
|
604
|
+
* - SQLite
|
|
644
605
|
*
|
|
645
|
-
*
|
|
646
|
-
* @type {Object} backup
|
|
647
|
-
* @property {string} backup.table
|
|
648
|
-
* @property {string} backup.filePath
|
|
649
|
-
* @type {object?} backup.connection
|
|
650
|
-
* @property {string} backup.connection.host
|
|
651
|
-
* @property {number} backup.connection.port
|
|
652
|
-
* @property {number} backup.connection.database
|
|
653
|
-
* @property {string} backup.connection.username
|
|
654
|
-
* @property {string} backup.connection.password
|
|
655
|
-
* @returns {Promise<void>}
|
|
656
|
-
*/
|
|
657
|
-
static backupTableToFile({ filePath, table, connection, }: TBackupTableToFile): Promise<void>;
|
|
658
|
-
/**
|
|
606
|
+
* MongoDB is not supported.
|
|
659
607
|
*
|
|
660
|
-
*
|
|
661
|
-
* @type {Object} backup
|
|
662
|
-
* @property {string} backup.database
|
|
663
|
-
* @property {string} backup.filePath
|
|
664
|
-
* @type {object?} backup.connection
|
|
665
|
-
* @property {string} backup.connection.host
|
|
666
|
-
* @property {number} backup.connection.port
|
|
667
|
-
* @property {number} backup.connection.database
|
|
668
|
-
* @property {string} backup.connection.username
|
|
669
|
-
* @property {string} backup.connection.password
|
|
670
|
-
* @returns {Promise<void>}
|
|
671
|
-
*/
|
|
672
|
-
backupTableSchemaToFile({ filePath, table, connection, }: TBackupTableToFile): Promise<void>;
|
|
673
|
-
/**
|
|
608
|
+
* @static
|
|
674
609
|
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
683
|
-
* @property {string} backup.connection.username
|
|
684
|
-
* @property {string} backup.connection.password
|
|
685
|
-
* @returns {Promise<void>}
|
|
610
|
+
* @example
|
|
611
|
+
* ```ts
|
|
612
|
+
* await DB.session().set('db', 'primary');
|
|
613
|
+
*
|
|
614
|
+
* const value = await db.session().get('db');
|
|
615
|
+
* console.log(value) // primary
|
|
616
|
+
*
|
|
617
|
+
* ```
|
|
686
618
|
*/
|
|
687
|
-
static
|
|
688
|
-
|
|
689
|
-
|
|
619
|
+
static session(): {
|
|
620
|
+
get(name: string): Promise<string | null>;
|
|
621
|
+
set(name: string, value: string): Promise<void>;
|
|
622
|
+
delete(name: string): Promise<void>;
|
|
623
|
+
};
|
|
690
624
|
private _initialDB;
|
|
691
625
|
}
|
|
692
626
|
export { DB };
|