tspace-mysql 1.9.3 → 1.9.4-beta.10

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.
Files changed (129) hide show
  1. package/README.md +497 -80
  2. package/dist/cli/dump/db.js +3 -15
  3. package/dist/cli/dump/db.js.map +1 -1
  4. package/dist/cli/index.js +0 -3
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/cli/migrations/make-db.js +1 -1
  7. package/dist/cli/migrations/make-db.js.map +1 -1
  8. package/dist/cli/migrations/make-model.js +1 -6
  9. package/dist/cli/migrations/make-model.js.map +1 -1
  10. package/dist/lib/config/index.d.ts +4 -4
  11. package/dist/lib/config/index.js +16 -7
  12. package/dist/lib/config/index.js.map +1 -1
  13. package/dist/lib/constants/index.d.ts +2 -2
  14. package/dist/lib/constants/index.js +9 -2
  15. package/dist/lib/constants/index.js.map +1 -1
  16. package/dist/lib/core/Abstracts/AbstractBuilder.d.ts +3 -2
  17. package/dist/lib/core/Abstracts/AbstractBuilder.js +1 -0
  18. package/dist/lib/core/Abstracts/AbstractBuilder.js.map +1 -1
  19. package/dist/lib/core/Abstracts/AbstractDB.d.ts +5 -3
  20. package/dist/lib/core/Abstracts/AbstractDB.js.map +1 -1
  21. package/dist/lib/core/Abstracts/AbstractModel.d.ts +1 -2
  22. package/dist/lib/core/Abstracts/AbstractModel.js +0 -1
  23. package/dist/lib/core/Abstracts/AbstractModel.js.map +1 -1
  24. package/dist/lib/core/Abstracts/AbstractView.d.ts +2 -1
  25. package/dist/lib/core/Abstracts/AbstractView.js.map +1 -1
  26. package/dist/lib/core/Blueprint.d.ts +56 -13
  27. package/dist/lib/core/Blueprint.js +58 -2
  28. package/dist/lib/core/Blueprint.js.map +1 -1
  29. package/dist/lib/core/Builder.d.ts +172 -19
  30. package/dist/lib/core/Builder.js +574 -210
  31. package/dist/lib/core/Builder.js.map +1 -1
  32. package/dist/lib/core/Cache/DBCache.js +6 -5
  33. package/dist/lib/core/Cache/DBCache.js.map +1 -1
  34. package/dist/lib/core/Cache/index.js +1 -1
  35. package/dist/lib/core/Cache/index.js.map +1 -1
  36. package/dist/lib/core/Contracts/Audit.d.ts +7 -5
  37. package/dist/lib/core/Contracts/Audit.js +18 -2
  38. package/dist/lib/core/Contracts/Audit.js.map +1 -1
  39. package/dist/lib/core/Contracts/Logger.d.ts +2 -2
  40. package/dist/lib/core/DB.d.ts +242 -169
  41. package/dist/lib/core/DB.js +559 -524
  42. package/dist/lib/core/DB.js.map +1 -1
  43. package/dist/lib/core/Driver/index.d.ts +41 -15
  44. package/dist/lib/core/Driver/index.js +14 -0
  45. package/dist/lib/core/Driver/index.js.map +1 -1
  46. package/dist/lib/core/Driver/mariadb/MariadbDriver.d.ts +6 -2
  47. package/dist/lib/core/Driver/mariadb/MariadbDriver.js +24 -7
  48. package/dist/lib/core/Driver/mariadb/MariadbDriver.js.map +1 -1
  49. package/dist/lib/core/Driver/mariadb/MariadbQueryBuilder.d.ts +42 -17
  50. package/dist/lib/core/Driver/mariadb/MariadbQueryBuilder.js +281 -154
  51. package/dist/lib/core/Driver/mariadb/MariadbQueryBuilder.js.map +1 -1
  52. package/dist/lib/core/Driver/mongodb/MongodbDriver.d.ts +7 -3
  53. package/dist/lib/core/Driver/mongodb/MongodbDriver.js +11 -6
  54. package/dist/lib/core/Driver/mongodb/MongodbDriver.js.map +1 -1
  55. package/dist/lib/core/Driver/mongodb/MongodbQueryBuilder.d.ts +40 -15
  56. package/dist/lib/core/Driver/mongodb/MongodbQueryBuilder.js +205 -157
  57. package/dist/lib/core/Driver/mongodb/MongodbQueryBuilder.js.map +1 -1
  58. package/dist/lib/core/Driver/mysql/MysqlDriver.d.ts +6 -2
  59. package/dist/lib/core/Driver/mysql/MysqlDriver.js +29 -7
  60. package/dist/lib/core/Driver/mysql/MysqlDriver.js.map +1 -1
  61. package/dist/lib/core/Driver/mysql/MysqlQueryBuilder.d.ts +42 -17
  62. package/dist/lib/core/Driver/mysql/MysqlQueryBuilder.js +251 -144
  63. package/dist/lib/core/Driver/mysql/MysqlQueryBuilder.js.map +1 -1
  64. package/dist/lib/core/Driver/postgres/PostgresDriver.d.ts +6 -2
  65. package/dist/lib/core/Driver/postgres/PostgresDriver.js +27 -8
  66. package/dist/lib/core/Driver/postgres/PostgresDriver.js.map +1 -1
  67. package/dist/lib/core/Driver/postgres/PostgresQueryBuilder.d.ts +45 -19
  68. package/dist/lib/core/Driver/postgres/PostgresQueryBuilder.js +471 -287
  69. package/dist/lib/core/Driver/postgres/PostgresQueryBuilder.js.map +1 -1
  70. package/dist/lib/core/Driver/sqlite/SqliteDriver.d.ts +6 -2
  71. package/dist/lib/core/Driver/sqlite/SqliteDriver.js +18 -7
  72. package/dist/lib/core/Driver/sqlite/SqliteDriver.js.map +1 -1
  73. package/dist/lib/core/Driver/sqlite/SqliteQueryBuilder.d.ts +47 -19
  74. package/dist/lib/core/Driver/sqlite/SqliteQueryBuilder.js +331 -203
  75. package/dist/lib/core/Driver/sqlite/SqliteQueryBuilder.js.map +1 -1
  76. package/dist/lib/core/Model.d.ts +541 -36
  77. package/dist/lib/core/Model.js +726 -81
  78. package/dist/lib/core/Model.js.map +1 -1
  79. package/dist/lib/core/Package.d.ts +5 -0
  80. package/dist/lib/core/Package.js +7 -2
  81. package/dist/lib/core/Package.js.map +1 -1
  82. package/dist/lib/core/Pool.d.ts +1 -1
  83. package/dist/lib/core/Pool.js +57 -73
  84. package/dist/lib/core/Pool.js.map +1 -1
  85. package/dist/lib/core/{Queue.d.ts → Queue/index.d.ts} +112 -117
  86. package/dist/lib/core/Queue/index.js +283 -0
  87. package/dist/lib/core/Queue/index.js.map +1 -0
  88. package/dist/lib/core/Queue/types.d.ts +68 -0
  89. package/dist/lib/core/Queue/types.js +3 -0
  90. package/dist/lib/core/Queue/types.js.map +1 -0
  91. package/dist/lib/core/Queue/worker-lock.d.ts +17 -0
  92. package/dist/lib/core/Queue/worker-lock.js +28 -0
  93. package/dist/lib/core/Queue/worker-lock.js.map +1 -0
  94. package/dist/lib/core/Queue/worker.d.ts +113 -0
  95. package/dist/lib/core/Queue/worker.js +853 -0
  96. package/dist/lib/core/Queue/worker.js.map +1 -0
  97. package/dist/lib/core/RelationManager.js +1 -1
  98. package/dist/lib/core/RelationManager.js.map +1 -1
  99. package/dist/lib/core/Repository.d.ts +175 -20
  100. package/dist/lib/core/Repository.js +180 -18
  101. package/dist/lib/core/Repository.js.map +1 -1
  102. package/dist/lib/core/Schema.d.ts +11 -7
  103. package/dist/lib/core/Schema.js +249 -80
  104. package/dist/lib/core/Schema.js.map +1 -1
  105. package/dist/lib/core/SqlLike.js +4 -4
  106. package/dist/lib/core/SqlLike.js.map +1 -1
  107. package/dist/lib/core/StateManager.d.ts +19 -0
  108. package/dist/lib/core/StateManager.js +9 -4
  109. package/dist/lib/core/StateManager.js.map +1 -1
  110. package/dist/lib/core/UtilityTypes.d.ts +24 -6
  111. package/dist/lib/core/UtilityTypes.js.map +1 -1
  112. package/dist/lib/core/View.d.ts +3 -1
  113. package/dist/lib/core/View.js +18 -25
  114. package/dist/lib/core/View.js.map +1 -1
  115. package/dist/lib/core/index.d.ts +2 -0
  116. package/dist/lib/core/index.js +3 -1
  117. package/dist/lib/core/index.js.map +1 -1
  118. package/dist/lib/types/decorator/index.d.ts +3 -0
  119. package/dist/lib/types/index.d.ts +93 -105
  120. package/dist/lib/types/repository/index.d.ts +20 -28
  121. package/dist/lib/utils/index.d.ts +16 -7
  122. package/dist/lib/utils/index.js +127 -24
  123. package/dist/lib/utils/index.js.map +1 -1
  124. package/package.json +3 -6
  125. package/dist/cli/dump/table.d.ts +0 -4
  126. package/dist/cli/dump/table.js +0 -41
  127. package/dist/cli/dump/table.js.map +0 -1
  128. package/dist/lib/core/Queue.js +0 -726
  129. package/dist/lib/core/Queue.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { AbstractDB } from "./Abstracts/AbstractDB";
2
- import type { TConstant, TBackup, TBackupTableToFile, TBackupToFile, TPoolConnected, TConnectionOptions, TConnectionTransaction, TRawStringQuery, TFreezeStringQuery, TPoolEvent, TConnection } from "../types";
2
+ import type { TConstant, TClone, TDump, TPoolConnected, TConnectionOptions, TConnection, 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
@@ -57,25 +57,128 @@ declare class DB extends AbstractDB {
57
57
  *
58
58
  * @param {string} sql
59
59
  * @param {Record<string,any>} parameters
60
- * @returns {promise<any[]>}
60
+ * @returns {Promise<T>}
61
+ *
62
+ * @example
63
+ * Execute a query without parameters:
64
+ * ```ts
65
+ * const users = await db.query(
66
+ * 'SELECT * FROM users'
67
+ * );
68
+ * ```
69
+ *
70
+ * @example
71
+ * Execute a query with named parameters:
72
+ * ```ts
73
+ * const user = await db.query(
74
+ * 'SELECT * FROM users WHERE id = :id',
75
+ * { id: 1 }
76
+ * );
77
+ * ```
78
+ *
79
+ * @example
80
+ * Execute a query with multiple parameters:
81
+ * ```ts
82
+ * const users = await db.query(
83
+ * 'SELECT * FROM users WHERE status = :status AND age >= :age',
84
+ * {
85
+ * status: 'active',
86
+ * age: 18,
87
+ * }
88
+ * );
89
+ * ```
90
+ *
91
+ * @example
92
+ * Use an array parameter:
93
+ * ```ts
94
+ * const users = await db.query(
95
+ * 'SELECT * FROM users WHERE id IN :ids',
96
+ * {
97
+ * ids: [1, 2, 3],
98
+ * }
99
+ * );
100
+ * ```
101
+ *
102
+ * @example
103
+ * Positional parameters using `?` placeholders:
104
+ * ```ts
105
+ * const users = await db.query<User[]>(
106
+ * 'SELECT * FROM users WHERE id = ? AND status = ?',
107
+ * [1, 'active']
108
+ * );
109
+ * ```
61
110
  */
62
- query(sql: string, parameters?: Record<string, any>): Promise<any>;
111
+ query<T = any>(sql: string, parameters?: (boolean | number | string | any[] | null)[] | Record<string, any>): Promise<T>;
63
112
  /**
64
113
  * The 'query' method is used to execute sql statement
65
114
  *
115
+ * @static
66
116
  * @param {string} sql
67
117
  * @param {Record<string,any>} parameters
68
- * @returns {promise<any[]>}
118
+ * @returns {Promise<T>}
119
+ *
120
+ * @example
121
+ * Execute a query without parameters:
122
+ * ```ts
123
+ * const users = await db.query(
124
+ * 'SELECT * FROM users'
125
+ * );
126
+ * ```
127
+ *
128
+ * @example
129
+ * Execute a query with named parameters:
130
+ * ```ts
131
+ * const user = await db.query(
132
+ * 'SELECT * FROM users WHERE id = :id',
133
+ * { id: 1 }
134
+ * );
135
+ * ```
136
+ *
137
+ * @example
138
+ * Execute a query with multiple parameters:
139
+ * ```ts
140
+ * const users = await db.query(
141
+ * 'SELECT * FROM users WHERE status = :status AND age >= :age',
142
+ * {
143
+ * status: 'active',
144
+ * age: 18,
145
+ * }
146
+ * );
147
+ * ```
148
+ *
149
+ * @example
150
+ * Use an array parameter:
151
+ * ```ts
152
+ * const users = await db.query(
153
+ * 'SELECT * FROM users WHERE id IN :ids',
154
+ * {
155
+ * ids: [1, 2, 3],
156
+ * }
157
+ * );
158
+ * ```
159
+ *
160
+ * @example
161
+ * Positional parameters using `?` placeholders:
162
+ * ```ts
163
+ * const users = await db.query<User[]>(
164
+ * 'SELECT * FROM users WHERE id = ? AND status = ?',
165
+ * [1, 'active']
166
+ * );
167
+ * ```
69
168
  */
70
- static query(sql: string, parameters?: Record<string, any>): Promise<any[]>;
169
+ static query<T = any>(sql: string, parameters?: (boolean | number | string | any[] | null)[] | Record<string, any>): Promise<T>;
71
170
  /**
72
171
  * The 'from' method is used to define the from table name.
172
+ *
173
+ * @static
73
174
  * @param {string} table table name
74
175
  * @returns {this} this
75
176
  */
76
177
  static from(table: string): DB;
77
178
  /**
78
179
  * The 'table' method is used to define the table name.
180
+ *
181
+ * @static
79
182
  * @param {string} table table name
80
183
  * @returns {DB} DB
81
184
  */
@@ -83,11 +186,19 @@ declare class DB extends AbstractDB {
83
186
  /**
84
187
  * The 'alias' method is used to set the table name.
85
188
  *
189
+ * @static
86
190
  * @param {string} sql raw sql from make a new alias for this table
87
191
  * @param {string} alias alias name
88
192
  * @returns {DB} DB
89
193
  */
90
194
  static alias(sql: string, alias: string): DB;
195
+ /**
196
+ *
197
+ * @static
198
+ * @override
199
+ * @returns {this} this
200
+ */
201
+ static dd(debug?: boolean): DB;
91
202
  /**
92
203
  * The 'jsonObject' method is used to specify select data to JSON objects.
93
204
  * @param {string} object table name
@@ -97,6 +208,7 @@ declare class DB extends AbstractDB {
97
208
  jsonObject(object: Record<string, string>, alias: string): string;
98
209
  /**
99
210
  * The 'jsonObject' method is used to specify select data to JSON objects.
211
+ *
100
212
  * @static
101
213
  * @param {string} object table name
102
214
  * @param {string} alias
@@ -105,6 +217,7 @@ declare class DB extends AbstractDB {
105
217
  static jsonObject(object: Record<string, string>, alias: string): string;
106
218
  /**
107
219
  * The 'JSONObject' method is used to specify select data to JSON objects.
220
+ *
108
221
  * @param {string} object table name
109
222
  * @param {string} alias
110
223
  * @returns {string} string
@@ -112,6 +225,7 @@ declare class DB extends AbstractDB {
112
225
  JSONObject(object: Record<string, string>, alias: string): string;
113
226
  /**
114
227
  * The 'JSONObject' method is used to specify select data to JSON objects.
228
+ *
115
229
  * @static
116
230
  * @param {string} object table name
117
231
  * @param {string} alias
@@ -126,6 +240,7 @@ declare class DB extends AbstractDB {
126
240
  constants(key?: keyof TConstant): string | object;
127
241
  /**
128
242
  * The 'constants' method is used to return constants with key or none in 'DB' or 'Model'.
243
+ *
129
244
  * @static
130
245
  * @param {string} key
131
246
  * @returns {string | object} string || object
@@ -143,6 +258,7 @@ declare class DB extends AbstractDB {
143
258
  }[], final?: string): string | [];
144
259
  /**
145
260
  * select by cases
261
+ *
146
262
  * @static
147
263
  * @param {arrayObject} cases array object {when , then }
148
264
  * @param {string?} final else condition
@@ -153,16 +269,26 @@ declare class DB extends AbstractDB {
153
269
  then: string;
154
270
  }[], final?: string): string | [];
155
271
  /**
156
- * 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.
157
276
  * @returns {string} string
158
277
  */
159
- generateUUID(): string;
278
+ generateUUID({ v }?: {
279
+ v?: 4 | 7;
280
+ }): string;
160
281
  /**
161
- * 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.
162
286
  * @static
163
287
  * @returns {string} string
164
288
  */
165
- static generateUUID(): string;
289
+ static generateUUID({ v }?: {
290
+ v?: 4 | 7;
291
+ }): string;
166
292
  /**
167
293
  * The 'snakeCase' methid is used to covert value to snakeCase pattern.
168
294
  * @returns {string} string
@@ -190,6 +316,8 @@ declare class DB extends AbstractDB {
190
316
  escape(value: string): string;
191
317
  /**
192
318
  * The 'escape' methid is used to escaping SQL injections.
319
+ *
320
+ * @static
193
321
  * @returns {string} string
194
322
  */
195
323
  static escape(value: string): string;
@@ -200,6 +328,8 @@ declare class DB extends AbstractDB {
200
328
  escapeXSS(value: string): string;
201
329
  /**
202
330
  * The 'escapeXSS' methid is used to escaping XSS characters.
331
+ *
332
+ * @static
203
333
  * @returns {string} string
204
334
  */
205
335
  static escapeXSS(value: string): string;
@@ -224,7 +354,7 @@ declare class DB extends AbstractDB {
224
354
  * )
225
355
  * .findOne();
226
356
  */
227
- raw(sql: string, parameters?: (boolean | number | string | any[] | null)[]): TRawStringQuery;
357
+ raw(sql: string, parameters?: (boolean | number | string | any[] | null)[] | Record<string, any>): TRawStringQuery;
228
358
  /**
229
359
  * The 'raw' methid is used to allow for raw sql queries to some method in 'DB' or 'Model'.
230
360
  * Creates a raw SQL query with optional parameter bindings.
@@ -247,7 +377,7 @@ declare class DB extends AbstractDB {
247
377
  * )
248
378
  * .findOne();
249
379
  */
250
- static raw(sql: string, parameters?: (boolean | number | string | any[] | null)[]): TRawStringQuery;
380
+ static raw(sql: string, parameters?: (boolean | number | string | any[] | null)[] | Record<string, any>): TRawStringQuery;
251
381
  /**
252
382
  * The 'freeze' methid is used to freeze the column without any pattern.
253
383
  *
@@ -294,9 +424,8 @@ declare class DB extends AbstractDB {
294
424
  *
295
425
  * Transactions are typically used when you want to ensure that a series of database operations either all succeed or all fail together,
296
426
  * ensuring data integrity.
297
- * @param {object} options
298
- * @property {number | undefined} options.primaryId
299
- * @property {number | undefined} options.nodeId
427
+ *
428
+ * @param {TPoolConnected} pool
300
429
  * @returns {ConnectionTransaction} object - Connection for the transaction
301
430
  * @type {object} connection
302
431
  * @property {function} connection.query - execute query sql then release connection to pool
@@ -304,10 +433,7 @@ declare class DB extends AbstractDB {
304
433
  * @property {function} connection.commit - commit transaction of query
305
434
  * @property {function} connection.rollback - rollback transaction of query
306
435
  */
307
- beginTransaction(options?: {
308
- primaryId?: number;
309
- nodeId?: number;
310
- }): Promise<TConnectionTransaction>;
436
+ beginTransaction(pool?: TPoolConnected): Promise<TConnection>;
311
437
  /**
312
438
  * The 'beginTransaction' is a method used to initiate a database transaction within your application's code.
313
439
  *
@@ -315,10 +441,9 @@ declare class DB extends AbstractDB {
315
441
  *
316
442
  * Transactions are typically used when you want to ensure that a series of database operations either all succeed or all fail together,
317
443
  * ensuring data integrity.
318
- * @param {object} options
319
- * @property {number | undefined} options.primaryId
320
- * @property {number | undefined} options.nodeId
321
444
  * @static
445
+ *
446
+ * @param {TPoolConnected} pool
322
447
  * @returns {ConnectionTransaction} object - Connection for the transaction
323
448
  * @type {object} connection
324
449
  * @property {function} connection.query - execute query sql then release connection to pool
@@ -326,12 +451,9 @@ declare class DB extends AbstractDB {
326
451
  * @property {function} connection.commit - commit transaction of query
327
452
  * @property {function} connection.rollback - rollback transaction of query
328
453
  */
329
- static beginTransaction(options?: {
330
- primaryId?: number;
331
- nodeId?: number;
332
- }): Promise<TConnectionTransaction>;
454
+ static beginTransaction(pool?: TPoolConnected): Promise<TConnection>;
333
455
  /**
334
- * Execute a database transaction.
456
+ * The 'transaction' is a method used to Execute a database transaction.
335
457
  *
336
458
  * This method will:
337
459
  * - Acquire a connection from the pool
@@ -347,9 +469,11 @@ declare class DB extends AbstractDB {
347
469
  * @returns {Promise<T>} The result returned from the handler.
348
470
  *
349
471
  */
350
- transaction<T>(handler: (conn: TConnection) => Promise<T>): Promise<T>;
472
+ transaction<T>(handler: (conn: TConnection) => Promise<T>, { pool }?: {
473
+ pool?: TPoolConnected;
474
+ }): Promise<T>;
351
475
  /**
352
- * Execute a database transaction.
476
+ * The 'transaction' is a method used to Execute a database transaction.
353
477
  *
354
478
  * This method will:
355
479
  * - Acquire a connection from the pool
@@ -358,6 +482,7 @@ declare class DB extends AbstractDB {
358
482
  * - Commit if successful
359
483
  * - Rollback if any error occurs
360
484
  *
485
+ * @static
361
486
  * @template T
362
487
  * @param {(conn: TConnection) => Promise<T>} handler - Async function that receives the transaction connection.
363
488
  * All queries inside this handler MUST use the provided `conn` instance.
@@ -365,7 +490,9 @@ declare class DB extends AbstractDB {
365
490
  * @returns {Promise<T>} The result returned from the handler.
366
491
  *
367
492
  */
368
- static transaction<T>(handler: (conn: TConnection) => Promise<T>): Promise<T>;
493
+ static transaction<T>(handler: (conn: TConnection) => Promise<T>, { pool }?: {
494
+ pool?: TPoolConnected;
495
+ }): Promise<T>;
369
496
  /**
370
497
  * The 'getActiveConnections' method is used to return active connections
371
498
  *
@@ -375,6 +502,7 @@ declare class DB extends AbstractDB {
375
502
  /**
376
503
  * The 'getActiveConnections' method is used to return active connections
377
504
  *
505
+ * @static
378
506
  * @returns {Promise<number>} this
379
507
  */
380
508
  static getActiveConnections(): Promise<number>;
@@ -387,175 +515,120 @@ declare class DB extends AbstractDB {
387
515
  /**
388
516
  * The 'getMaxConnections' method is used to return max connections
389
517
  *
518
+ * @static
390
519
  * @returns {Promise<number>} this
391
520
  */
392
521
  static getMaxConnections(): Promise<number>;
393
522
  /**
394
- * The 'removeProperties' method is used to removed some properties.
523
+ * This'clone' method is used to clone the current database into a new database
524
+ * on the same server or another server.
395
525
  *
396
- * @param {Array | Record} data
397
- * @param {string[]} propertiesToRemoves
398
- * @returns {Array | Record} this
526
+ * @property {string} database - Target database name.
527
+ * @property {string[]} excludes - Tables to exclude from the clone.
528
+ * @property {object} to - Target server connection.
529
+ * @property {string} to.host - Target server host.
530
+ * @property {number} to.port - Target server port.
531
+ * @property {string} to.username - Target server username.
532
+ * @property {string} to.password - Target server password.
533
+ * @returns {Promise<void>}
399
534
  */
400
- removeProperties(data: any[] | Record<string, any>, propertiesToRemoves: string[]): Array<any> | Record<string, any>;
535
+ clone({ database, excludes, only, value, to }: TClone): Promise<void>;
401
536
  /**
402
- * The 'removeProperties' method is used to removed some properties.
403
- *
404
- * @param {Array | Record} data
405
- * @param {string[]} propertiesToRemoves
406
- * @returns {Array | Record} this
407
- */
408
- static removeProperties(data: any[] | Record<string, any>, propertiesToRemoves: string[]): Array<any> | Record<string, any>;
537
+ * This'clone' method is used to clone the current database into a new database
538
+ * on the same server or another server.
539
+ *
540
+ * @static
541
+ * @property {string} database - Target database name.
542
+ * @property {string[]} excludes - Tables to exclude from the clone.
543
+ * @property {object} to - Target server connection.
544
+ * @property {string} to.host - Target server host.
545
+ * @property {number} to.port - Target server port.
546
+ * @property {string} to.username - Target server username.
547
+ * @property {string} to.password - Target server password.
548
+ * @returns {Promise<void>}
549
+ */
550
+ static clone({ database, only, excludes, value, to }: TClone): Promise<void>;
409
551
  /**
410
552
  *
411
- * This 'backup' method is used to backup database intro new database same server or to another server
412
- * @type {Object} backup
413
- * @property {string} backup.database clone current 'db' in connection to this database
414
- * @type {object?} backup.to
415
- * @property {string} backup.to.host
416
- * @property {number} backup.to.port
417
- * @property {string} backup.to.username
418
- * @property {string} backup.to.password
553
+ * This 'dump' method is used to Dumps a database into a SQL file
554
+ * @type {Object} opt
555
+ * @property {string?} opt.database
556
+ * @property {string} opt.filePath
557
+ * @property {string[]} opt.excludes
558
+ * @property {boolean?} opt.value
419
559
  * @returns {Promise<void>}
420
560
  */
421
- backup({ database, to }: TBackup): Promise<void>;
561
+ dump({ filePath, excludes, only, database, value }: TDump): Promise<void>;
422
562
  /**
563
+ * This 'dump' method is used to Dumps a database into a SQL file
423
564
  *
424
- * This 'backup' method is used to backup database intro new database same server or to another server
425
- * @type {Object} backup
426
- * @property {string} backup.database clone current 'db' in connection to this database
427
- * @type {object?} backup.to
428
- * @property {string} backup.to.host
429
- * @property {number} backup.to.port
430
- * @property {string} backup.to.username
431
- * @property {string} backup.to.password
565
+ * @static
566
+ * @type {Object} opt
567
+ * @property {string?} opt.database
568
+ * @property {string} opt.filePath
569
+ * @property {string[]} opt.excludes
570
+ * @property {boolean?} opt.value
432
571
  * @returns {Promise<void>}
433
572
  */
434
- static backup({ database, to }: TBackup): Promise<void>;
573
+ static dump({ filePath, database, excludes, only, value, }: TDump): Promise<void>;
435
574
  /**
575
+ * This 'session' method is used to manage database session variables.
436
576
  *
437
- * This 'backupToFile' method is used to backup database intro new ${file}.sql
438
- * @type {Object} backup
439
- * @property {string} backup.database
440
- * @property {string} backup.filePath
441
- * @type {object?} backup.connection
442
- * @property {string} backup.connection.host
443
- * @property {number} backup.connection.port
444
- * @property {number} backup.connection.database
445
- * @property {string} backup.connection.username
446
- * @property {string} backup.connection.password
447
- * @returns {Promise<void>}
448
- */
449
- backupToFile({ filePath, database, connection, }: TBackupToFile): Promise<void>;
450
- /**
577
+ * Provides methods to get and set session variables for the current
578
+ * database connection.
451
579
  *
452
- * This 'backupToFile' method is used to backup database intro new ${file}.sql
453
- * @type {Object} backup
454
- * @property {string} backup.database
455
- * @property {string} backup.filePath
456
- * @type {object?} backup.connection
457
- * @property {string} backup.connection.host
458
- * @property {number} backup.connection.port
459
- * @property {number} backup.connection.database
460
- * @property {string} backup.connection.username
461
- * @property {string} backup.connection.password
462
- * @returns {Promise<void>}
463
- */
464
- static backupToFile({ filePath, database, connection, }: TBackupToFile): Promise<void>;
465
- /**
580
+ * Supported drivers:
581
+ * - MySQL
582
+ * - MariaDB
583
+ * - PostgreSQL
584
+ * - SQLite
466
585
  *
467
- * This 'backupSchemaToFile' method is used to backup database intro new ${file}.sql
468
- * @type {Object} backup
469
- * @property {string} backup.database
470
- * @property {string} backup.filePath
471
- * @type {object?} backup.connection
472
- * @property {string} backup.connection.host
473
- * @property {number} backup.connection.port
474
- * @property {number} backup.connection.database
475
- * @property {string} backup.connection.username
476
- * @property {string} backup.connection.password
477
- * @returns {Promise<void>}
478
- */
479
- backupSchemaToFile({ filePath, database, connection, }: TBackupToFile): Promise<void>;
480
- /**
586
+ * MongoDB is not supported.
481
587
  *
482
- * This 'backupSchemaToFile' method is used to backup database intro new ${file}.sql
588
+ * @example
589
+ * ```ts
590
+ * await DB.session().set('db', 'primary');
483
591
  *
484
- * @type {Object} backup
485
- * @property {string} backup.database
486
- * @property {string} backup.filePath
487
- * @type {object?} backup.connection
488
- * @property {string} backup.connection.host
489
- * @property {number} backup.connection.port
490
- * @property {number} backup.connection.database
491
- * @property {string} backup.connection.username
492
- * @property {string} backup.connection.password
493
- * @returns {Promise<void>}
592
+ * const value = await db.session().get('db');
593
+ * console.log(value) // primary
594
+ *
595
+ * ```
494
596
  */
495
- static backupSchemaToFile({ filePath, database, connection, }: TBackupToFile): Promise<void>;
597
+ session(): {
598
+ get(name: string): Promise<string | null>;
599
+ set(name: string, value: string): Promise<void>;
600
+ delete(name: string): Promise<void>;
601
+ };
496
602
  /**
603
+ * This 'session' method is used to manage database session variables.
497
604
  *
498
- * This 'backupTableToFile' method is used to backup database intro new ${file}.sql
605
+ * Provides methods to get and set session variables for the current
606
+ * database connection.
499
607
  *
500
- * @type {Object} backup
501
- * @property {string} backup.database
502
- * @property {string} backup.filePath
503
- * @type {object?} backup.connection
504
- * @property {string} backup.connection.host
505
- * @property {number} backup.connection.port
506
- * @property {number} backup.connection.database
507
- * @property {string} backup.connection.username
508
- * @property {string} backup.connection.password
509
- * @returns {Promise<void>}
510
- */
511
- backupTableToFile({ filePath, table, connection, }: TBackupTableToFile): Promise<void>;
512
- /**
608
+ * Supported drivers:
609
+ * - MySQL
610
+ * - MariaDB
611
+ * - PostgreSQL
612
+ * - SQLite
513
613
  *
514
- * This 'backupTableSchemaToFile' method is used to backup database intro new ${file}.sql
515
- * @type {Object} backup
516
- * @property {string} backup.table
517
- * @property {string} backup.filePath
518
- * @type {object?} backup.connection
519
- * @property {string} backup.connection.host
520
- * @property {number} backup.connection.port
521
- * @property {number} backup.connection.database
522
- * @property {string} backup.connection.username
523
- * @property {string} backup.connection.password
524
- * @returns {Promise<void>}
525
- */
526
- static backupTableToFile({ filePath, table, connection, }: TBackupTableToFile): Promise<void>;
527
- /**
614
+ * MongoDB is not supported.
528
615
  *
529
- * This 'backupTableSchemaToFile' method is used to backup database intro new ${file}.sql
530
- * @type {Object} backup
531
- * @property {string} backup.database
532
- * @property {string} backup.filePath
533
- * @type {object?} backup.connection
534
- * @property {string} backup.connection.host
535
- * @property {number} backup.connection.port
536
- * @property {number} backup.connection.database
537
- * @property {string} backup.connection.username
538
- * @property {string} backup.connection.password
539
- * @returns {Promise<void>}
540
- */
541
- backupTableSchemaToFile({ filePath, table, connection, }: TBackupTableToFile): Promise<void>;
542
- /**
616
+ * @static
543
617
  *
544
- * This 'backupTableSchemaToFile' method is used to backup database intro new ${file}.sql
545
- * @type {Object} backup
546
- * @property {string} backup.table
547
- * @property {string} backup.filePath
548
- * @type {object?} backup.connection
549
- * @property {string} backup.connection.host
550
- * @property {number} backup.connection.port
551
- * @property {number} backup.connection.database
552
- * @property {string} backup.connection.username
553
- * @property {string} backup.connection.password
554
- * @returns {Promise<void>}
618
+ * @example
619
+ * ```ts
620
+ * await DB.session().set('db', 'primary');
621
+ *
622
+ * const value = await db.session().get('db');
623
+ * console.log(value) // primary
624
+ *
625
+ * ```
555
626
  */
556
- static backupTableSchemaToFile({ filePath, table, connection, }: TBackupTableToFile): Promise<void>;
557
- private _backup;
558
- private _backupToString;
627
+ static session(): {
628
+ get(name: string): Promise<string | null>;
629
+ set(name: string, value: string): Promise<void>;
630
+ delete(name: string): Promise<void>;
631
+ };
559
632
  private _initialDB;
560
633
  }
561
634
  export { DB };