gg-mysql-connector 1.0.111 → 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.
@@ -1,24 +1,36 @@
1
-
2
- export const app_model_const = { item : {
3
- id: "number",
4
- name: ["pen" , "ruler" , "tiger"] as string[],
5
- price: "number",
6
- description: "string",
7
- amount: "number",
8
- userId: "number", }, item__stock : {
9
- id: "number",
10
- userId: "number",
11
- itemId: "number",
12
- amount: "number", }, user : {
13
- id: "number",
14
- name: "string", }, item__each_user : {
15
- id: "number",
16
- itemId: "number",
17
- userId: "number", }, test_view : {
18
- id: "number",
19
- name: "string",
20
- itemName: ["pen" , "ruler" , "tiger"] as string[], }, item_view : {
21
- id: "number",
22
- name: ["pen" , "ruler" , "tiger"] as string[],
23
- amount: "number",
24
- price: "number", } } as const
1
+ export const app_model_const = {
2
+ item: {
3
+ id: "number",
4
+ name: ["pen", "ruler", "tiger"] as const,
5
+ price: "number",
6
+ description: "string",
7
+ amount: "number",
8
+ userId: "number",
9
+ },
10
+ item__stock: {
11
+ id: "number",
12
+ userId: "number",
13
+ itemId: "number",
14
+ amount: "number",
15
+ },
16
+ user: {
17
+ id: "number",
18
+ name: "string",
19
+ },
20
+ item__each_user: {
21
+ id: "number",
22
+ itemId: "number",
23
+ userId: "number",
24
+ },
25
+ test_view: {
26
+ id: "number",
27
+ name: "string",
28
+ itemName: ["pen", "ruler", "tiger"] as const,
29
+ },
30
+ item_view: {
31
+ id: "number",
32
+ name: ["pen", "ruler", "tiger"] as const,
33
+ amount: "number",
34
+ price: "number",
35
+ },
36
+ } as const
@@ -1,7 +1,7 @@
1
1
  export declare const app_model_const: {
2
2
  readonly item: {
3
3
  readonly id: "number";
4
- readonly name: string[];
4
+ readonly name: readonly ["pen", "ruler", "tiger"];
5
5
  readonly price: "number";
6
6
  readonly description: "string";
7
7
  readonly amount: "number";
@@ -25,11 +25,11 @@ export declare const app_model_const: {
25
25
  readonly test_view: {
26
26
  readonly id: "number";
27
27
  readonly name: "string";
28
- readonly itemName: string[];
28
+ readonly itemName: readonly ["pen", "ruler", "tiger"];
29
29
  };
30
30
  readonly item_view: {
31
31
  readonly id: "number";
32
- readonly name: string[];
32
+ readonly name: readonly ["pen", "ruler", "tiger"];
33
33
  readonly amount: "number";
34
34
  readonly price: "number";
35
35
  };
@@ -1,32 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.app_model_const = void 0;
4
- exports.app_model_const = { item: {
4
+ exports.app_model_const = {
5
+ item: {
5
6
  id: "number",
6
7
  name: ["pen", "ruler", "tiger"],
7
8
  price: "number",
8
9
  description: "string",
9
10
  amount: "number",
10
11
  userId: "number",
11
- }, item__stock: {
12
+ },
13
+ item__stock: {
12
14
  id: "number",
13
15
  userId: "number",
14
16
  itemId: "number",
15
17
  amount: "number",
16
- }, user: {
18
+ },
19
+ user: {
17
20
  id: "number",
18
21
  name: "string",
19
- }, item__each_user: {
22
+ },
23
+ item__each_user: {
20
24
  id: "number",
21
25
  itemId: "number",
22
26
  userId: "number",
23
- }, test_view: {
27
+ },
28
+ test_view: {
24
29
  id: "number",
25
30
  name: "string",
26
31
  itemName: ["pen", "ruler", "tiger"],
27
- }, item_view: {
32
+ },
33
+ item_view: {
28
34
  id: "number",
29
35
  name: ["pen", "ruler", "tiger"],
30
36
  amount: "number",
31
37
  price: "number",
32
- } };
38
+ },
39
+ };
@@ -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;
@@ -264,6 +264,12 @@ class ModelGenerator {
264
264
  if (columnChecker || tableName.search("_view") >= 0) {
265
265
  const possibleValue = this.getPossibleColumnValue(params.model, cRow.TABLE_NAME, cRow.COLUMN_NAME, cRow.COLUMN_TYPE);
266
266
  if (possibleValue) {
267
+ // value = `${value} \n ${cRow.COLUMN_NAME}: [${possibleValue
268
+ // .map((row) => {
269
+ // if (typeof row === "string") return `"${row}"`
270
+ // else if (typeof row === "number") return `${row}`
271
+ // })
272
+ // .join(" , ")}] as ${typeof possibleValue[0]}[],`
267
273
  value = `${value} \n ${cRow.COLUMN_NAME}: [${possibleValue
268
274
  .map((row) => {
269
275
  if (typeof row === "string")
@@ -271,7 +277,7 @@ class ModelGenerator {
271
277
  else if (typeof row === "number")
272
278
  return `${row}`;
273
279
  })
274
- .join(" , ")}] as ${typeof possibleValue[0]}[],`;
280
+ .join(" , ")}] as const,`;
275
281
  }
276
282
  else {
277
283
  value = `${value} \n ${cRow.COLUMN_NAME}: "${(0, convertDataType_1.convertDataType)(cRow.DATA_TYPE)}",`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg-mysql-connector",
3
- "version": "1.0.111",
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
@@ -356,12 +356,18 @@ export default class ModelGenerator {
356
356
  cRow.COLUMN_TYPE
357
357
  )
358
358
  if (possibleValue) {
359
+ // value = `${value} \n ${cRow.COLUMN_NAME}: [${possibleValue
360
+ // .map((row) => {
361
+ // if (typeof row === "string") return `"${row}"`
362
+ // else if (typeof row === "number") return `${row}`
363
+ // })
364
+ // .join(" , ")}] as ${typeof possibleValue[0]}[],`
359
365
  value = `${value} \n ${cRow.COLUMN_NAME}: [${possibleValue
360
366
  .map((row) => {
361
367
  if (typeof row === "string") return `"${row}"`
362
368
  else if (typeof row === "number") return `${row}`
363
369
  })
364
- .join(" , ")}] as ${typeof possibleValue[0]}[],`
370
+ .join(" , ")}] as const,`
365
371
  } else {
366
372
  value = `${value} \n ${cRow.COLUMN_NAME}: "${convertDataType(
367
373
  cRow.DATA_TYPE