gg-mysql-connector 1.0.112 → 1.0.114

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,7 +36,11 @@ 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
+ selectByDateRange<T extends keyof Main>(tableName: T extends string ? T : never, params: {
40
+ columnName: keyof Main[T];
41
+ startDate: string;
42
+ endDate: string;
43
+ }): Promise<Main[T][]>;
40
44
  createDatabaseIfNotExist(tempConnection: mysql.Pool): Promise<void>;
41
45
  selectBySearchTextInRow(tableName: string, textToSearch: string): Promise<mysql.RowDataPacket[]>;
42
46
  loadTableAndViewNameList(): Promise<string[]>;
@@ -26,8 +26,10 @@ class GGMySQLConnector {
26
26
  this.DBInfo = DBInfo;
27
27
  this.isConnected = false;
28
28
  }
29
- selectByDateRange(tableName, params) {
30
- throw new Error("Method not implemented.");
29
+ async selectByDateRange(tableName, params) {
30
+ const { columnName, endDate, startDate } = params;
31
+ const result = (await this.query(`SELECT * FROM ${tableName} WHERE ? <= ? AND ? <= ?`, [tableName, startDate, columnName, columnName, endDate], false));
32
+ return result;
31
33
  }
32
34
  async createDatabaseIfNotExist(tempConnection) {
33
35
  const currentDatabaseName = this.DBInfo.database;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-mysql-connector",
3
- "version": "1.0.112",
3
+ "version": "1.0.114",
4
4
  "description": "",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {
@@ -81,11 +81,21 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
81
81
  this.DBInfo = DBInfo
82
82
  this.isConnected = false
83
83
  }
84
- selectByDateRange<T extends keyof Main>(
85
- tableName: T extends string ? T : string,
86
- params: object
84
+ async selectByDateRange<T extends keyof Main>(
85
+ tableName: T extends string ? T : never,
86
+ params: {
87
+ columnName: keyof Main[T]
88
+ startDate: string
89
+ endDate: string
90
+ }
87
91
  ): Promise<Main[T][]> {
88
- throw new Error("Method not implemented.")
92
+ const { columnName, endDate, startDate } = params
93
+ const result = (await this.query(
94
+ `SELECT * FROM ${tableName} WHERE ? <= ? AND ? <= ?`,
95
+ [tableName, startDate, columnName, columnName, endDate],
96
+ false
97
+ )) as Main[T][]
98
+ return result
89
99
  }
90
100
  async createDatabaseIfNotExist(tempConnection: mysql.Pool): Promise<void> {
91
101
  const currentDatabaseName = this.DBInfo.database