gg-mysql-connector 1.0.118 → 1.0.121

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,14 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
36
36
  }[] | null;
37
37
  isConnected: boolean;
38
38
  constructor(DBInfo: DatabaseConfigInterface);
39
+ /**
40
+ * Select rows from a table within a date range.
41
+ * @description
42
+ * This function filters records where:
43
+ * startDate <= columnName <= endDate
44
+ *
45
+ * @returns Promise of rows from Main[T] within the date range
46
+ */
39
47
  selectByDateRange<T extends keyof Main>(tableName: T extends string ? T : never, params: {
40
48
  columnName: keyof Main[T];
41
49
  startDate: string;
@@ -27,9 +27,17 @@ class GGMySQLConnector {
27
27
  this.isConnected = false;
28
28
  this.connection = null;
29
29
  }
30
+ /**
31
+ * Select rows from a table within a date range.
32
+ * @description
33
+ * This function filters records where:
34
+ * startDate <= columnName <= endDate
35
+ *
36
+ * @returns Promise of rows from Main[T] within the date range
37
+ */
30
38
  async selectByDateRange(tableName, params) {
31
39
  const { columnName, endDate, startDate } = params;
32
- const result = (await this.query(`SELECT * FROM ${tableName} WHERE ? <= ? AND ? <= ?`, [tableName, startDate, columnName, columnName, endDate], false));
40
+ const result = (await this.query(`SELECT ${tableName} FROM ? WHERE ? <= ? AND ? <= ?`, [startDate, columnName, columnName, endDate], false));
33
41
  return result;
34
42
  }
35
43
  async createDatabaseIfNotExist(tempConnection) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-mysql-connector",
3
- "version": "1.0.118",
3
+ "version": "1.0.121",
4
4
  "description": "",
5
5
  "main": "dist/src/index.js",
6
6
  "scripts": {
@@ -82,6 +82,15 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
82
82
  this.isConnected = false
83
83
  this.connection = null
84
84
  }
85
+
86
+ /**
87
+ * Select rows from a table within a date range.
88
+ * @description
89
+ * This function filters records where:
90
+ * startDate <= columnName <= endDate
91
+ *
92
+ * @returns Promise of rows from Main[T] within the date range
93
+ */
85
94
  async selectByDateRange<T extends keyof Main>(
86
95
  tableName: T extends string ? T : never,
87
96
  params: {
@@ -92,8 +101,8 @@ export default class GGMySQLConnector<Main> implements ClassDBInterface<Main> {
92
101
  ): Promise<Main[T][]> {
93
102
  const { columnName, endDate, startDate } = params
94
103
  const result = (await this.query(
95
- `SELECT * FROM ${tableName} WHERE ? <= ? AND ? <= ?`,
96
- [tableName, startDate, columnName, columnName, endDate],
104
+ `SELECT ${tableName} FROM ? WHERE ? <= ? AND ? <= ?`,
105
+ [startDate, columnName, columnName, endDate],
97
106
  false
98
107
  )) as Main[T][]
99
108
  return result