tspace-mysql 1.8.2 → 1.8.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.
@@ -1,5 +1,5 @@
1
- import { AbstractDB } from './Abstracts/AbstractDB';
2
- import type { TConstant, TBackup, TBackupTableToFile, TBackupToFile, TConnection, TConnectionOptions, TConnectionTransaction, TRawStringQuery, TFreezeStringQuery } from '../types';
1
+ import { AbstractDB } from "./Abstracts/AbstractDB";
2
+ import type { TConstant, TBackup, TBackupTableToFile, TBackupToFile, TConnection, TConnectionOptions, TConnectionTransaction, TRawStringQuery, TFreezeStringQuery } from "../types";
3
3
  /**
4
4
  * 'DB' Class is a component of the database system
5
5
  * @param {string?} table table name
@@ -206,15 +206,15 @@ declare class DB extends AbstractDB {
206
206
  */
207
207
  getConnection(options?: TConnectionOptions): Promise<TConnection>;
208
208
  /**
209
- * The 'getConnection' method is used to get a pool connection.
210
- * @param {Object} options options for connection database with credentials
211
- * @property {string} option.host
212
- * @property {number} option.port
213
- * @property {string} option.database
214
- * @property {string} option.username
215
- * @property {string} option.password
216
- * @returns {Connection}
217
- */
209
+ * The 'getConnection' method is used to get a pool connection.
210
+ * @param {Object} options options for connection database with credentials
211
+ * @property {string} option.host
212
+ * @property {number} option.port
213
+ * @property {string} option.database
214
+ * @property {string} option.username
215
+ * @property {string} option.password
216
+ * @returns {Connection}
217
+ */
218
218
  static getConnection(options: TConnectionOptions): Promise<TConnection>;
219
219
  /**
220
220
  * The 'beginTransaction' is a method used to initiate a database transaction within your application's code.
@@ -271,11 +271,11 @@ declare class DB extends AbstractDB {
271
271
  */
272
272
  cloneDB(database: string): Promise<void>;
273
273
  /**
274
- *
275
- * This 'cloneDB' method is used to clone current database to new database
276
- * @param {string} database clone current database to new database name
277
- * @returns {Promise<boolean>}
278
- */
274
+ *
275
+ * This 'cloneDB' method is used to clone current database to new database
276
+ * @param {string} database clone current database to new database name
277
+ * @returns {Promise<boolean>}
278
+ */
279
279
  static cloneDB(database: string): Promise<void>;
280
280
  /**
281
281
  *
@@ -317,22 +317,22 @@ declare class DB extends AbstractDB {
317
317
  * @property {string} backup.connection.password
318
318
  * @returns {Promise<void>}
319
319
  */
320
- backupToFile({ filePath, database, connection }: TBackupToFile): Promise<void>;
321
- /**
322
- *
323
- * This 'backupToFile' method is used to backup database intro new ${file}.sql
324
- * @type {Object} backup
325
- * @property {string} backup.database
326
- * @property {string} backup.filePath
327
- * @type {object?} backup.connection
328
- * @property {string} backup.connection.host
329
- * @property {number} backup.connection.port
330
- * @property {number} backup.connection.database
331
- * @property {string} backup.connection.username
332
- * @property {string} backup.connection.password
333
- * @returns {Promise<void>}
334
- */
335
- static backupToFile({ filePath, database, connection }: TBackupToFile): Promise<void>;
320
+ backupToFile({ filePath, database, connection, }: TBackupToFile): Promise<void>;
321
+ /**
322
+ *
323
+ * This 'backupToFile' method is used to backup database intro new ${file}.sql
324
+ * @type {Object} backup
325
+ * @property {string} backup.database
326
+ * @property {string} backup.filePath
327
+ * @type {object?} backup.connection
328
+ * @property {string} backup.connection.host
329
+ * @property {number} backup.connection.port
330
+ * @property {number} backup.connection.database
331
+ * @property {string} backup.connection.username
332
+ * @property {string} backup.connection.password
333
+ * @returns {Promise<void>}
334
+ */
335
+ static backupToFile({ filePath, database, connection, }: TBackupToFile): Promise<void>;
336
336
  /**
337
337
  *
338
338
  * This 'backupSchemaToFile' method is used to backup database intro new ${file}.sql
@@ -347,7 +347,7 @@ declare class DB extends AbstractDB {
347
347
  * @property {string} backup.connection.password
348
348
  * @returns {Promise<void>}
349
349
  */
350
- backupSchemaToFile({ filePath, database, connection }: TBackupToFile): Promise<void>;
350
+ backupSchemaToFile({ filePath, database, connection, }: TBackupToFile): Promise<void>;
351
351
  /**
352
352
  *
353
353
  * This 'backupSchemaToFile' method is used to backup database intro new ${file}.sql
@@ -363,7 +363,7 @@ declare class DB extends AbstractDB {
363
363
  * @property {string} backup.connection.password
364
364
  * @returns {Promise<void>}
365
365
  */
366
- static backupSchemaToFile({ filePath, database, connection }: TBackupToFile): Promise<void>;
366
+ static backupSchemaToFile({ filePath, database, connection, }: TBackupToFile): Promise<void>;
367
367
  /**
368
368
  *
369
369
  * This 'backupTableToFile' method is used to backup database intro new ${file}.sql
@@ -379,7 +379,7 @@ declare class DB extends AbstractDB {
379
379
  * @property {string} backup.connection.password
380
380
  * @returns {Promise<void>}
381
381
  */
382
- backupTableToFile({ filePath, table, connection }: TBackupTableToFile): Promise<void>;
382
+ backupTableToFile({ filePath, table, connection, }: TBackupTableToFile): Promise<void>;
383
383
  /**
384
384
  *
385
385
  * This 'backupTableSchemaToFile' method is used to backup database intro new ${file}.sql
@@ -394,7 +394,7 @@ declare class DB extends AbstractDB {
394
394
  * @property {string} backup.connection.password
395
395
  * @returns {Promise<void>}
396
396
  */
397
- static backupTableToFile({ filePath, table, connection }: TBackupTableToFile): Promise<void>;
397
+ static backupTableToFile({ filePath, table, connection, }: TBackupTableToFile): Promise<void>;
398
398
  /**
399
399
  *
400
400
  * This 'backupTableSchemaToFile' method is used to backup database intro new ${file}.sql
@@ -409,7 +409,7 @@ declare class DB extends AbstractDB {
409
409
  * @property {string} backup.connection.password
410
410
  * @returns {Promise<void>}
411
411
  */
412
- backupTableSchemaToFile({ filePath, table, connection }: TBackupTableToFile): Promise<void>;
412
+ backupTableSchemaToFile({ filePath, table, connection, }: TBackupTableToFile): Promise<void>;
413
413
  /**
414
414
  *
415
415
  * This 'backupTableSchemaToFile' method is used to backup database intro new ${file}.sql
@@ -424,7 +424,7 @@ declare class DB extends AbstractDB {
424
424
  * @property {string} backup.connection.password
425
425
  * @returns {Promise<void>}
426
426
  */
427
- static backupTableSchemaToFile({ filePath, table, connection }: TBackupTableToFile): Promise<void>;
427
+ static backupTableSchemaToFile({ filePath, table, connection, }: TBackupTableToFile): Promise<void>;
428
428
  private _backup;
429
429
  private _initialDB;
430
430
  }
@@ -24,7 +24,7 @@ exports.DB = void 0;
24
24
  const sql_formatter_1 = require("sql-formatter");
25
25
  const AbstractDB_1 = require("./Abstracts/AbstractDB");
26
26
  const Proxy_1 = require("./Handlers/Proxy");
27
- const connection_1 = require("../connection");
27
+ const Pool_1 = require("./Pool");
28
28
  const State_1 = require("./Handlers/State");
29
29
  const tools_1 = require("../tools");
30
30
  /**
@@ -64,7 +64,7 @@ class DB extends AbstractDB_1.AbstractDB {
64
64
  for (const key in parameters) {
65
65
  const parameter = parameters[key];
66
66
  if (parameter === null) {
67
- bindSql = bindSql.replace(`:${key}`, this.$constants('NULL'));
67
+ bindSql = bindSql.replace(`:${key}`, this.$constants("NULL"));
68
68
  continue;
69
69
  }
70
70
  if (parameter === true || parameter === false) {
@@ -72,7 +72,7 @@ class DB extends AbstractDB_1.AbstractDB {
72
72
  continue;
73
73
  }
74
74
  bindSql = bindSql.replace(`:${key}`, Array.isArray(parameter)
75
- ? `(${parameter.map(p => `'${this.escape(p)}'`).join(',')})`
75
+ ? `(${parameter.map((p) => `'${this.escape(p)}'`).join(",")})`
76
76
  : `'${this.escape(parameter)}'`);
77
77
  }
78
78
  return yield this.rawQuery(bindSql);
@@ -130,13 +130,17 @@ class DB extends AbstractDB_1.AbstractDB {
130
130
  let maping = [];
131
131
  for (const [key, value] of Object.entries(object)) {
132
132
  if (/\./.test(value)) {
133
- const [table, c] = value.split('.');
133
+ const [table, c] = value.split(".");
134
134
  maping = [...maping, `'${key}'`, `\`${table}\`.\`${c}\``];
135
135
  continue;
136
136
  }
137
- maping = [...maping, `'${key}'`, `\`${this.getTableName()}\`.\`${value}\``];
137
+ maping = [
138
+ ...maping,
139
+ `'${key}'`,
140
+ `\`${this.getTableName()}\`.\`${value}\``,
141
+ ];
138
142
  }
139
- return `${this.$constants('JSON_OBJECT')}(${maping.join(' , ')}) ${this.$constants('AS')} \`${alias}\``;
143
+ return `${this.$constants("JSON_OBJECT")}(${maping.join(" , ")}) ${this.$constants("AS")} \`${alias}\``;
140
144
  }
141
145
  /**
142
146
  * The 'jsonObject' method is used to specify select data to JSON objects.
@@ -201,16 +205,16 @@ class DB extends AbstractDB_1.AbstractDB {
201
205
  throw new Error(`can't find then condition`);
202
206
  query = [
203
207
  ...query,
204
- `${this.$constants('WHEN')} ${c.when} ${this.$constants('THEN')} ${c.then}`
208
+ `${this.$constants("WHEN")} ${c.when} ${this.$constants("THEN")} ${c.then}`,
205
209
  ];
206
210
  }
207
211
  return [
208
- this.$constants('RAW'),
209
- this.$constants('CASE'),
210
- query.join(' '),
211
- final == null ? '' : `ELSE ${final}`,
212
- this.$constants('END')
213
- ].join(' ');
212
+ this.$constants("RAW"),
213
+ this.$constants("CASE"),
214
+ query.join(" "),
215
+ final == null ? "" : `ELSE ${final}`,
216
+ this.$constants("END"),
217
+ ].join(" ");
214
218
  }
215
219
  /**
216
220
  * select by cases
@@ -299,7 +303,7 @@ class DB extends AbstractDB_1.AbstractDB {
299
303
  * @returns {string} string
300
304
  */
301
305
  raw(sql) {
302
- return `${this.$constants('RAW')}${sql}`;
306
+ return `${this.$constants("RAW")}${sql}`;
303
307
  }
304
308
  /**
305
309
  * The 'raw' methid is used to allow for raw sql queries to some method in 'DB' or 'Model'.
@@ -317,7 +321,7 @@ class DB extends AbstractDB_1.AbstractDB {
317
321
  * @returns {string} string
318
322
  */
319
323
  freeze(column) {
320
- return `${this.$constants('FREEZE')}${column}`;
324
+ return `${this.$constants("FREEZE")}${column}`;
321
325
  }
322
326
  /**
323
327
  * The 'freeze' methid is used to freeze the column without any pattern.
@@ -343,27 +347,27 @@ class DB extends AbstractDB_1.AbstractDB {
343
347
  return __awaiter(this, void 0, void 0, function* () {
344
348
  if (options == null) {
345
349
  const pool = yield this.$pool.get();
346
- return yield pool.connection();
350
+ return yield pool.newConnection();
347
351
  }
348
352
  const { host, port, database, username: user, password } = options, others = __rest(options, ["host", "port", "database", "username", "password"]);
349
- const pool = new connection_1.PoolConnection(Object.assign({ host,
353
+ const pool = new Pool_1.PoolConnection(Object.assign({ host,
350
354
  port,
351
355
  database,
352
356
  user,
353
357
  password }, others));
354
- return pool.connected();
358
+ return pool.newConnected();
355
359
  });
356
360
  }
357
361
  /**
358
- * The 'getConnection' method is used to get a pool connection.
359
- * @param {Object} options options for connection database with credentials
360
- * @property {string} option.host
361
- * @property {number} option.port
362
- * @property {string} option.database
363
- * @property {string} option.username
364
- * @property {string} option.password
365
- * @returns {Connection}
366
- */
362
+ * The 'getConnection' method is used to get a pool connection.
363
+ * @param {Object} options options for connection database with credentials
364
+ * @property {string} option.host
365
+ * @property {number} option.port
366
+ * @property {string} option.database
367
+ * @property {string} option.username
368
+ * @property {string} option.password
369
+ * @returns {Connection}
370
+ */
367
371
  static getConnection(options) {
368
372
  return __awaiter(this, void 0, void 0, function* () {
369
373
  return new this().getConnection(options);
@@ -385,7 +389,7 @@ class DB extends AbstractDB_1.AbstractDB {
385
389
  */
386
390
  beginTransaction() {
387
391
  return __awaiter(this, void 0, void 0, function* () {
388
- const pool = new connection_1.PoolConnection().connected();
392
+ const pool = new Pool_1.PoolConnection().newConnected();
389
393
  return yield pool.connection();
390
394
  });
391
395
  }
@@ -418,7 +422,7 @@ class DB extends AbstractDB_1.AbstractDB {
418
422
  */
419
423
  removeProperties(data, propertiesToRemoves) {
420
424
  const setNestedProperty = (obj, path, value) => {
421
- const segments = path.split('.');
425
+ const segments = path.split(".");
422
426
  let currentObj = obj;
423
427
  for (let i = 0; i < segments.length - 1; i++) {
424
428
  const segment = segments[i];
@@ -435,16 +439,16 @@ class DB extends AbstractDB_1.AbstractDB {
435
439
  for (const property of propertiesToRemoves) {
436
440
  if (property == null)
437
441
  continue;
438
- const properties = property.split('.');
442
+ const properties = property.split(".");
439
443
  let current = temp;
440
- let afterProp = '';
444
+ let afterProp = "";
441
445
  const props = [];
442
446
  for (let i = 0; i < properties.length - 1; i++) {
443
447
  const prop = properties[i];
444
448
  if (current[prop] == null)
445
449
  continue;
446
450
  props.push(prop);
447
- if (typeof current[prop] === 'object' && current[prop] != null) {
451
+ if (typeof current[prop] === "object" && current[prop] != null) {
448
452
  current = current[prop];
449
453
  afterProp = prop;
450
454
  continue;
@@ -454,7 +458,7 @@ class DB extends AbstractDB_1.AbstractDB {
454
458
  }
455
459
  const lastProp = properties[properties.length - 1];
456
460
  if (Array.isArray(current)) {
457
- setNestedProperty(temp, props.join('.'), this.removeProperties(current, [afterProp, lastProp]));
461
+ setNestedProperty(temp, props.join("."), this.removeProperties(current, [afterProp, lastProp]));
458
462
  continue;
459
463
  }
460
464
  if (current[lastProp] == null)
@@ -464,7 +468,7 @@ class DB extends AbstractDB_1.AbstractDB {
464
468
  return temp;
465
469
  };
466
470
  if (Array.isArray(data)) {
467
- return data.map(obj => remove(obj, propertiesToRemoves));
471
+ return data.map((obj) => remove(obj, propertiesToRemoves));
468
472
  }
469
473
  return remove(data, propertiesToRemoves);
470
474
  }
@@ -487,30 +491,30 @@ class DB extends AbstractDB_1.AbstractDB {
487
491
  cloneDB(database) {
488
492
  return __awaiter(this, void 0, void 0, function* () {
489
493
  var _a;
490
- const db = yield this._queryStatement(`${this.$constants('SHOW_DATABASES')} ${this.$constants('LIKE')} '${database}'`);
494
+ const db = yield this._queryStatement(`${this.$constants("SHOW_DATABASES")} ${this.$constants("LIKE")} '${database}'`);
491
495
  if (Object.values((_a = db[0]) !== null && _a !== void 0 ? _a : []).length)
492
496
  throw new Error(`This database : '${database}' is already exists`);
493
497
  const tables = yield this.showTables();
494
498
  const backup = yield this._backup({ tables, database });
495
- yield this._queryStatement(`${this.$constants('CREATE_DATABASE_NOT_EXISTS')} \`${database}\``);
496
- const creating = (_b) => __awaiter(this, [_b], void 0, function* ({ table, values }) {
499
+ yield this._queryStatement(`${this.$constants("CREATE_DATABASE_NOT_EXISTS")} \`${database}\``);
500
+ const creating = (_b) => __awaiter(this, [_b], void 0, function* ({ table, values, }) {
497
501
  try {
498
502
  yield this._queryStatement(table);
499
- if (values != null && values !== '')
503
+ if (values != null && values !== "")
500
504
  yield this._queryStatement(values);
501
505
  }
502
506
  catch (e) { }
503
507
  });
504
- yield Promise.all(backup.map(b => creating({ table: b.table, values: b.values })));
508
+ yield Promise.all(backup.map((b) => creating({ table: b.table, values: b.values })));
505
509
  return;
506
510
  });
507
511
  }
508
512
  /**
509
- *
510
- * This 'cloneDB' method is used to clone current database to new database
511
- * @param {string} database clone current database to new database name
512
- * @returns {Promise<boolean>}
513
- */
513
+ *
514
+ * This 'cloneDB' method is used to clone current database to new database
515
+ * @param {string} database clone current database to new database name
516
+ * @returns {Promise<boolean>}
517
+ */
514
518
  static cloneDB(database) {
515
519
  return __awaiter(this, void 0, void 0, function* () {
516
520
  return new this().cloneDB(database);
@@ -567,29 +571,30 @@ class DB extends AbstractDB_1.AbstractDB {
567
571
  * @returns {Promise<void>}
568
572
  */
569
573
  backupToFile(_a) {
570
- return __awaiter(this, arguments, void 0, function* ({ filePath, database = `dump_${+new Date()}`, connection }) {
574
+ return __awaiter(this, arguments, void 0, function* ({ filePath, database = `dump_${+new Date()}`, connection, }) {
571
575
  var _b;
572
576
  yield this.$utils.wait(1000 * 3);
573
577
  const tables = yield this.showTables();
574
- const backup = (yield this._backup({ tables, database }))
575
- .map(b => {
578
+ const backup = (yield this._backup({ tables, database })).map((b) => {
576
579
  return {
577
580
  table: [
578
581
  `\n--`,
579
582
  `-- Table structure for table '${b.name}'`,
580
583
  `--\n`,
581
584
  `${(0, sql_formatter_1.format)(b.table, {
582
- language: 'spark',
585
+ language: "spark",
583
586
  tabWidth: 2,
584
- linesBetweenQueries: 1
585
- })}`
586
- ].join('\n'),
587
- values: b.values !== '' ? [
588
- `\n--`,
589
- `-- Dumping data for table '${b.name}'`,
590
- `--\n`,
591
- `${b.values}`
592
- ].join('\n') : ''
587
+ linesBetweenQueries: 1,
588
+ })}`,
589
+ ].join("\n"),
590
+ values: b.values !== ""
591
+ ? [
592
+ `\n--`,
593
+ `-- Dumping data for table '${b.name}'`,
594
+ `--\n`,
595
+ `${b.values}`,
596
+ ].join("\n")
597
+ : "",
593
598
  };
594
599
  });
595
600
  if (connection != null && ((_b = Object.keys(connection)) === null || _b === void 0 ? void 0 : _b.length))
@@ -606,9 +611,9 @@ class DB extends AbstractDB_1.AbstractDB {
606
611
  `--`,
607
612
  `-- Database: '${database}'`,
608
613
  `--\n`,
609
- `${this.$constants('CREATE_DATABASE_NOT_EXISTS')} \`${database}\`;`,
614
+ `${this.$constants("CREATE_DATABASE_NOT_EXISTS")} \`${database}\`;`,
610
615
  `USE \`${database}\`;`,
611
- `-- --------------------------------------------------------`
616
+ `-- --------------------------------------------------------`,
612
617
  ];
613
618
  for (const b of backup) {
614
619
  sql = [...sql, b.table];
@@ -616,26 +621,26 @@ class DB extends AbstractDB_1.AbstractDB {
616
621
  sql = [...sql, b.values];
617
622
  }
618
623
  }
619
- tools_1.Tool.fs.writeFileSync(filePath, [...sql, 'COMMIT;'].join('\n'));
624
+ tools_1.Tool.fs.writeFileSync(filePath, [...sql, "COMMIT;"].join("\n"));
620
625
  return;
621
626
  });
622
627
  }
623
628
  /**
624
- *
625
- * This 'backupToFile' method is used to backup database intro new ${file}.sql
626
- * @type {Object} backup
627
- * @property {string} backup.database
628
- * @property {string} backup.filePath
629
- * @type {object?} backup.connection
630
- * @property {string} backup.connection.host
631
- * @property {number} backup.connection.port
632
- * @property {number} backup.connection.database
633
- * @property {string} backup.connection.username
634
- * @property {string} backup.connection.password
635
- * @returns {Promise<void>}
636
- */
629
+ *
630
+ * This 'backupToFile' method is used to backup database intro new ${file}.sql
631
+ * @type {Object} backup
632
+ * @property {string} backup.database
633
+ * @property {string} backup.filePath
634
+ * @type {object?} backup.connection
635
+ * @property {string} backup.connection.host
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
+ */
637
642
  static backupToFile(_a) {
638
- return __awaiter(this, arguments, void 0, function* ({ filePath, database, connection }) {
643
+ return __awaiter(this, arguments, void 0, function* ({ filePath, database, connection, }) {
639
644
  return new this().backupToFile({ filePath, database, connection });
640
645
  });
641
646
  }
@@ -654,32 +659,31 @@ class DB extends AbstractDB_1.AbstractDB {
654
659
  * @returns {Promise<void>}
655
660
  */
656
661
  backupSchemaToFile(_a) {
657
- return __awaiter(this, arguments, void 0, function* ({ filePath, database = `dump_${+new Date()}`, connection }) {
662
+ return __awaiter(this, arguments, void 0, function* ({ filePath, database = `dump_${+new Date()}`, connection, }) {
658
663
  var _b;
659
664
  if (connection != null && ((_b = Object.keys(connection)) === null || _b === void 0 ? void 0 : _b.length))
660
665
  this.connection(connection);
661
666
  yield this.$utils.wait(1000 * 3);
662
667
  const tables = yield this.showTables();
663
- const backup = (yield this._backup({ tables, database }))
664
- .map(b => {
668
+ const backup = (yield this._backup({ tables, database })).map((b) => {
665
669
  return {
666
670
  table: (0, sql_formatter_1.format)(b.table, {
667
- language: 'spark',
671
+ language: "spark",
668
672
  tabWidth: 2,
669
673
  linesBetweenQueries: 1,
670
- }) + "\n"
674
+ }) + "\n",
671
675
  };
672
676
  });
673
677
  let sql = [
674
678
  `SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";`,
675
679
  `START TRANSACTION;`,
676
680
  `SET time_zone = "+00:00";`,
677
- `${this.$constants('CREATE_DATABASE_NOT_EXISTS')} \`${database}\`;`,
678
- `USE \`${database}\`;`
681
+ `${this.$constants("CREATE_DATABASE_NOT_EXISTS")} \`${database}\`;`,
682
+ `USE \`${database}\`;`,
679
683
  ];
680
684
  for (const b of backup)
681
685
  sql = [...sql, b.table];
682
- tools_1.Tool.fs.writeFileSync(filePath, [...sql, 'COMMIT;'].join('\n'));
686
+ tools_1.Tool.fs.writeFileSync(filePath, [...sql, "COMMIT;"].join("\n"));
683
687
  return;
684
688
  });
685
689
  }
@@ -699,7 +703,7 @@ class DB extends AbstractDB_1.AbstractDB {
699
703
  * @returns {Promise<void>}
700
704
  */
701
705
  static backupSchemaToFile(_a) {
702
- return __awaiter(this, arguments, void 0, function* ({ filePath, database, connection }) {
706
+ return __awaiter(this, arguments, void 0, function* ({ filePath, database, connection, }) {
703
707
  return new this().backupSchemaToFile({ filePath, database, connection });
704
708
  });
705
709
  }
@@ -719,7 +723,7 @@ class DB extends AbstractDB_1.AbstractDB {
719
723
  * @returns {Promise<void>}
720
724
  */
721
725
  backupTableToFile(_a) {
722
- return __awaiter(this, arguments, void 0, function* ({ filePath, table, connection }) {
726
+ return __awaiter(this, arguments, void 0, function* ({ filePath, table, connection, }) {
723
727
  var _b;
724
728
  if (connection != null && ((_b = Object.keys(connection)) === null || _b === void 0 ? void 0 : _b.length))
725
729
  this.connection(connection);
@@ -730,31 +734,31 @@ class DB extends AbstractDB_1.AbstractDB {
730
734
  yield this.$utils.wait(1000 * 5);
731
735
  const schemas = yield this.showSchema(table);
732
736
  const createTableSQL = [
733
- `${this.$constants('CREATE_TABLE_NOT_EXISTS')}`,
737
+ `${this.$constants("CREATE_TABLE_NOT_EXISTS")}`,
734
738
  `\`${table}\``,
735
- `(${schemas.join(',')})`,
736
- `${this.$constants('ENGINE')};`,
739
+ `(${schemas.join(",")})`,
740
+ `${this.$constants("ENGINE")};`,
737
741
  ];
738
742
  const values = yield this.showValues(table);
739
743
  let valueSQL = [];
740
744
  if (values.length) {
741
745
  const columns = yield this.showColumns(table);
742
746
  valueSQL = [
743
- `${this.$constants('INSERT')}`,
747
+ `${this.$constants("INSERT")}`,
744
748
  `\`${table}\``,
745
- `(${columns.map((column) => `\`${column}\``).join(',')})`,
746
- `${this.$constants('VALUES')} ${values.join(',')};`
749
+ `(${columns.map((column) => `\`${column}\``).join(",")})`,
750
+ `${this.$constants("VALUES")} ${values.join(",")};`,
747
751
  ];
748
752
  }
749
753
  const sql = [
750
- (0, sql_formatter_1.format)(createTableSQL.join(' '), {
751
- language: 'mysql',
754
+ (0, sql_formatter_1.format)(createTableSQL.join(" "), {
755
+ language: "mysql",
752
756
  tabWidth: 2,
753
757
  linesBetweenQueries: 1,
754
758
  }) + "\n",
755
- valueSQL.join(' ')
759
+ valueSQL.join(" "),
756
760
  ];
757
- tools_1.Tool.fs.writeFileSync(filePath, [...sql, 'COMMIT;'].join('\n'));
761
+ tools_1.Tool.fs.writeFileSync(filePath, [...sql, "COMMIT;"].join("\n"));
758
762
  return;
759
763
  });
760
764
  }
@@ -773,7 +777,7 @@ class DB extends AbstractDB_1.AbstractDB {
773
777
  * @returns {Promise<void>}
774
778
  */
775
779
  static backupTableToFile(_a) {
776
- return __awaiter(this, arguments, void 0, function* ({ filePath, table, connection }) {
780
+ return __awaiter(this, arguments, void 0, function* ({ filePath, table, connection, }) {
777
781
  return new this().backupTableToFile({ filePath, table, connection });
778
782
  });
779
783
  }
@@ -792,21 +796,21 @@ class DB extends AbstractDB_1.AbstractDB {
792
796
  * @returns {Promise<void>}
793
797
  */
794
798
  backupTableSchemaToFile(_a) {
795
- return __awaiter(this, arguments, void 0, function* ({ filePath, table, connection }) {
799
+ return __awaiter(this, arguments, void 0, function* ({ filePath, table, connection, }) {
796
800
  var _b;
797
801
  const schemas = yield this.showSchema(table);
798
802
  const createTableSQL = [
799
- `${this.$constants('CREATE_TABLE_NOT_EXISTS')}`,
803
+ `${this.$constants("CREATE_TABLE_NOT_EXISTS")}`,
800
804
  `\`${table}\``,
801
- `(${schemas.join(',')})`,
802
- `${this.$constants('ENGINE')};`,
805
+ `(${schemas.join(",")})`,
806
+ `${this.$constants("ENGINE")};`,
803
807
  ];
804
- const sql = [createTableSQL.join(' ')];
808
+ const sql = [createTableSQL.join(" ")];
805
809
  if (connection != null && ((_b = Object.keys(connection)) === null || _b === void 0 ? void 0 : _b.length))
806
810
  this.connection(connection);
807
811
  yield this.$utils.wait(1000 * 5);
808
- tools_1.Tool.fs.writeFileSync(filePath, (0, sql_formatter_1.format)(sql.join('\n'), {
809
- language: 'spark',
812
+ tools_1.Tool.fs.writeFileSync(filePath, (0, sql_formatter_1.format)(sql.join("\n"), {
813
+ language: "spark",
810
814
  tabWidth: 2,
811
815
  linesBetweenQueries: 1,
812
816
  }));
@@ -828,44 +832,44 @@ class DB extends AbstractDB_1.AbstractDB {
828
832
  * @returns {Promise<void>}
829
833
  */
830
834
  static backupTableSchemaToFile(_a) {
831
- return __awaiter(this, arguments, void 0, function* ({ filePath, table, connection }) {
835
+ return __awaiter(this, arguments, void 0, function* ({ filePath, table, connection, }) {
832
836
  return new this().backupTableSchemaToFile({ filePath, table, connection });
833
837
  });
834
838
  }
835
839
  _backup(_a) {
836
- return __awaiter(this, arguments, void 0, function* ({ tables, database }) {
840
+ return __awaiter(this, arguments, void 0, function* ({ tables, database, }) {
837
841
  const backup = [];
838
842
  for (const table of tables) {
839
843
  const schemas = yield this.showSchema(table);
840
844
  const createTableSQL = [
841
- `${this.$constants('CREATE_TABLE_NOT_EXISTS')}`,
845
+ `${this.$constants("CREATE_TABLE_NOT_EXISTS")}`,
842
846
  `\`${database}\`.\`${table}\``,
843
- `(${schemas.join(', ')})`,
844
- `${this.$constants('ENGINE')};`,
847
+ `(${schemas.join(", ")})`,
848
+ `${this.$constants("ENGINE")};`,
845
849
  ];
846
850
  const values = yield this.showValues(table);
847
851
  let valueSQL = [];
848
852
  if (values.length) {
849
853
  const columns = yield this.showColumns(table);
850
854
  valueSQL = [
851
- `${this.$constants('INSERT')}`,
855
+ `${this.$constants("INSERT")}`,
852
856
  `\`${database}\`.\`${table}\``,
853
- `(${columns.map((column) => `\`${column}\``).join(', ')})`,
854
- `${this.$constants('VALUES')}`,
855
- `\n${values.join(',\n')};`
857
+ `(${columns.map((column) => `\`${column}\``).join(", ")})`,
858
+ `${this.$constants("VALUES")}`,
859
+ `\n${values.join(",\n")};`,
856
860
  ];
857
861
  }
858
862
  backup.push({
859
- name: table == null ? '' : table,
860
- table: createTableSQL.join(' '),
861
- values: valueSQL.join(' '),
863
+ name: table == null ? "" : table,
864
+ table: createTableSQL.join(" "),
865
+ values: valueSQL.join(" "),
862
866
  });
863
867
  }
864
868
  return backup;
865
869
  });
866
870
  }
867
871
  _initialDB() {
868
- this.$state = new State_1.StateHandler('db');
872
+ this.$state = new State_1.StateHandler("db");
869
873
  return this;
870
874
  }
871
875
  }