triangle-utils 1.4.127 → 1.4.129

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.
@@ -10,32 +10,48 @@ export declare class UtilsRDS {
10
10
  disconnect(): Promise<void>;
11
11
  query(sql: string, options?: {
12
12
  is_verbose?: boolean;
13
- }): Promise<any[]>;
13
+ }): Promise<import("pg").QueryResult<any>>;
14
14
  exec(sql: string, options?: {
15
15
  is_verbose?: boolean;
16
- }): Promise<any[]>;
16
+ }): Promise<{
17
+ [k: string]: unknown;
18
+ }[]>;
17
19
  get(table_id: string, primary_key: Record<string, any>, attribute_names?: string[], options?: {
18
20
  is_verbose?: boolean;
19
- }): Promise<Record<string, any> | undefined>;
21
+ }): Promise<Record<string, any>>;
20
22
  batch_get(table_id: string, primary_key: Record<string, any[]>, attribute_names?: string[], options?: {
21
23
  is_verbose?: boolean;
22
- }): Promise<any[]>;
24
+ }): Promise<{
25
+ [k: string]: unknown;
26
+ }[]>;
23
27
  create(table_id: string, item: Record<string, any>, options?: {
24
28
  is_verbose?: boolean;
25
- }): Promise<any[] | undefined>;
29
+ }): Promise<{
30
+ [k: string]: unknown;
31
+ }[] | undefined>;
26
32
  batch_create(table_id: string, items: Record<string, any>[], options?: {
27
33
  is_verbose?: boolean;
28
- }): Promise<any[] | undefined>;
34
+ }): Promise<{
35
+ [k: string]: unknown;
36
+ }[] | undefined>;
29
37
  put(table_id: string, item: Record<string, any>, options?: {
30
38
  is_verbose?: boolean;
31
- }): Promise<any[] | undefined>;
39
+ }): Promise<{
40
+ [k: string]: unknown;
41
+ }[] | undefined>;
32
42
  batch_put(table_id: string, items: Record<string, any>[], options?: {
33
43
  is_verbose?: boolean;
34
- }): Promise<any[] | undefined>;
44
+ }): Promise<{
45
+ [k: string]: unknown;
46
+ }[] | undefined>;
35
47
  delete(table_id: string, primary_key: Record<string, any>, options?: {
36
48
  is_verbose?: boolean;
37
- }): Promise<any[]>;
49
+ }): Promise<{
50
+ [k: string]: unknown;
51
+ }[]>;
38
52
  batch_delete(table_id: string, primary_key: Record<string, any[]>, options?: {
39
53
  is_verbose?: boolean;
40
- }): Promise<any[]>;
54
+ }): Promise<{
55
+ [k: string]: unknown;
56
+ }[]>;
41
57
  }
@@ -5,7 +5,7 @@ function convert_rds_input(input) {
5
5
  return "NULL";
6
6
  }
7
7
  else if (typeof input === "string") {
8
- return "'" + input.replace("'", "''") + "'";
8
+ return "'" + input.replaceAll("'", "''") + "'";
9
9
  }
10
10
  else if (typeof input === "number") {
11
11
  return input.toString();
@@ -63,7 +63,7 @@ export class UtilsRDS {
63
63
  }
64
64
  }
65
65
  const response = await this.postgres.query(sql);
66
- return response.rows;
66
+ return response;
67
67
  }
68
68
  async exec(sql, options = {}) {
69
69
  const is_verbose = Boolean(options.is_verbose);
@@ -87,7 +87,7 @@ export class UtilsRDS {
87
87
  }
88
88
  return [];
89
89
  }
90
- return items;
90
+ return items.map(item => Object.fromEntries(Object.entries(item).filter(([key, value]) => value !== null)));
91
91
  }
92
92
  async get(table_id, primary_key, attribute_names, options = {}) {
93
93
  const sql = "SELECT " + (attribute_names === undefined ? "*" : attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + Object.entries(primary_key).map(([key_name, value]) => key_name + " = " + convert_rds_input(value)).join(" AND ");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.127",
3
+ "version": "1.4.129",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/UtilsRDS.ts CHANGED
@@ -5,7 +5,7 @@ function convert_rds_input(input : string | boolean | number | Record<string, an
5
5
  if (input === undefined) {
6
6
  return "NULL"
7
7
  } else if (typeof input === "string") {
8
- return "'" + input.replace("'", "''") + "'"
8
+ return "'" + input.replaceAll("'", "''") + "'"
9
9
  } else if (typeof input === "number") {
10
10
  return input.toString()
11
11
  } else if (typeof input === "boolean") {
@@ -78,7 +78,7 @@ export class UtilsRDS {
78
78
  }
79
79
  }
80
80
  const response = await this.postgres.query(sql)
81
- return response.rows
81
+ return response
82
82
  }
83
83
 
84
84
  async exec(
@@ -108,7 +108,7 @@ export class UtilsRDS {
108
108
  }
109
109
  return []
110
110
  }
111
- return items
111
+ return items.map(item => Object.fromEntries(Object.entries(item).filter(([key, value]) => value !== null)))
112
112
  }
113
113
 
114
114
  async get(