gg-mysql-connector 1.0.88 → 1.0.90

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.
@@ -36,6 +36,7 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
36
36
  }[] | null;
37
37
  isConnected: boolean;
38
38
  constructor(DBInfo: DatabaseConfigInterface);
39
+ selectByDateRange<T extends keyof Main>(tableName: T extends string ? T : string, params: object): Promise<Main[T][]>;
39
40
  createDatabaseIfNotExist(tempConnection: mysql.Connection): Promise<void>;
40
41
  selectBySearchTextInRow(tableName: string, textToSearch: string): Promise<mysql.RowDataPacket[]>;
41
42
  loadTableAndViewNameList(): Promise<string[]>;
@@ -22,6 +22,9 @@ class GGMySQLConnector {
22
22
  this.DBInfo = DBInfo;
23
23
  this.isConnected = false;
24
24
  }
25
+ selectByDateRange(tableName, params) {
26
+ throw new Error("Method not implemented.");
27
+ }
25
28
  async createDatabaseIfNotExist(tempConnection) {
26
29
  const currentDatabaseName = this.DBInfo.database;
27
30
  console.log("currentDatabaseName", currentDatabaseName);
@@ -11,6 +11,7 @@ export default class ModelGenerator {
11
11
  dbInfo: DatabaseConfigInterface;
12
12
  connection: mysql.Connection;
13
13
  isConnected: boolean;
14
+ isForcePrintSQLStatement: boolean;
14
15
  constructor(dbInfo: DatabaseConfigInterface, model: MyModel[]);
15
16
  init(): Promise<void>;
16
17
  private createDatabaseIfNotExist;
@@ -23,6 +23,7 @@ class ModelGenerator {
23
23
  this.model = model;
24
24
  this.dbInfo = dbInfo;
25
25
  this.isConnected = false;
26
+ this.isForcePrintSQLStatement = false;
26
27
  }
27
28
  async init() {
28
29
  console.log("init");
@@ -73,6 +74,9 @@ class ModelGenerator {
73
74
  .then((result) => {
74
75
  const endTime = new Date();
75
76
  const executionTime = endTime.getTime() - startTime.getTime();
77
+ if (this.isForcePrintSQLStatement === true) {
78
+ console.log("sql query > ", chalk_1.default.green(statment), parameter);
79
+ }
76
80
  if (isPrint === true)
77
81
  this.printResultLength(result, executionTime, queryResult);
78
82
  resolve(result[0]);
@@ -27,8 +27,8 @@ class MyDBMigrator {
27
27
  await this.alterIndex(row.tableName, col.COLUMN_NAME, col.IS_INDEX);
28
28
  await this.alterPossibleEnum(row.tableName, col.COLUMN_NAME, col.POSSIBLE_VALUE);
29
29
  await this.alterForeignKey(row.tableName, col);
30
- await this.alterUniqueColumnCombination(row.tableName, row.compoisteUniqueColumn);
31
30
  }
31
+ await this.alterUniqueColumnCombination(row.tableName, row.compoisteUniqueColumn);
32
32
  }
33
33
  console.log("migrate table done");
34
34
  }
@@ -48,8 +48,8 @@ class MyDBMigrator {
48
48
  const compositeUniqueName = this.getCompositeUniqueName(compositeUniqueColumn);
49
49
  const sql = `SHOW INDEX FROM ${tableName} WHERE Non_unique = 0 AND Key_name like "${compositeUniqueName}"`;
50
50
  const data = (await this.MyDB.query(sql));
51
- console.log("sql", sql);
52
- console.log("isCompositeUniqueColumnExist", data.length, data);
51
+ // console.log("sql", sql)
52
+ // console.log("isCompositeUniqueColumnExist", data.length, data)
53
53
  return data.length ? true : false;
54
54
  }
55
55
  async alterForeignKey(tableName, col) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-mysql-connector",
3
- "version": "1.0.88",
3
+ "version": "1.0.90",
4
4
  "description": "",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {
@@ -73,6 +73,12 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
73
73
  this.DBInfo = DBInfo
74
74
  this.isConnected = false
75
75
  }
76
+ selectByDateRange<T extends keyof Main>(
77
+ tableName: T extends string ? T : string,
78
+ params: object
79
+ ): Promise<Main[T][]> {
80
+ throw new Error("Method not implemented.")
81
+ }
76
82
  async createDatabaseIfNotExist(
77
83
  tempConnection: mysql.Connection
78
84
  ): Promise<void> {
@@ -18,10 +18,12 @@ export default class ModelGenerator {
18
18
  dbInfo: DatabaseConfigInterface
19
19
  connection!: mysql.Connection
20
20
  isConnected: boolean
21
+ isForcePrintSQLStatement: boolean
21
22
  constructor(dbInfo: DatabaseConfigInterface, model: MyModel[]) {
22
23
  this.model = model
23
24
  this.dbInfo = dbInfo
24
25
  this.isConnected = false
26
+ this.isForcePrintSQLStatement = false
25
27
  }
26
28
  async init() {
27
29
  console.log("init")
@@ -78,6 +80,10 @@ export default class ModelGenerator {
78
80
  .then((result) => {
79
81
  const endTime = new Date()
80
82
  const executionTime = endTime.getTime() - startTime.getTime()
83
+
84
+ if (this.isForcePrintSQLStatement === true) {
85
+ console.log("sql query > ", chalk.green(statment), parameter)
86
+ }
81
87
  if (isPrint === true)
82
88
  this.printResultLength(result, executionTime, queryResult)
83
89
 
@@ -44,11 +44,11 @@ export default class MyDBMigrator {
44
44
  col.POSSIBLE_VALUE
45
45
  )
46
46
  await this.alterForeignKey(row.tableName, col)
47
- await this.alterUniqueColumnCombination(
48
- row.tableName,
49
- row.compoisteUniqueColumn
50
- )
51
47
  }
48
+ await this.alterUniqueColumnCombination(
49
+ row.tableName,
50
+ row.compoisteUniqueColumn
51
+ )
52
52
  }
53
53
  console.log("migrate table done")
54
54
  }
@@ -78,8 +78,8 @@ export default class MyDBMigrator {
78
78
  )
79
79
  const sql = `SHOW INDEX FROM ${tableName} WHERE Non_unique = 0 AND Key_name like "${compositeUniqueName}"`
80
80
  const data = (await this.MyDB.query(sql)) as any[]
81
- console.log("sql", sql)
82
- console.log("isCompositeUniqueColumnExist", data.length, data)
81
+ // console.log("sql", sql)
82
+ // console.log("isCompositeUniqueColumnExist", data.length, data)
83
83
  return data.length ? true : false
84
84
  }
85
85