triangle-utils 1.4.129 → 1.4.132
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.
- package/dist/src/UtilsRDS.d.ts +11 -25
- package/dist/src/UtilsRDS.js +6 -3
- package/dist/src/f.js +2 -0
- package/package.json +1 -1
- package/src/UtilsRDS.ts +6 -3
- package/src/f.ts +4 -1
package/dist/src/UtilsRDS.d.ts
CHANGED
|
@@ -10,48 +10,34 @@ export declare class UtilsRDS {
|
|
|
10
10
|
disconnect(): Promise<void>;
|
|
11
11
|
query(sql: string, options?: {
|
|
12
12
|
is_verbose?: boolean;
|
|
13
|
-
}): Promise<import("pg").QueryResult<any>>;
|
|
14
|
-
exec(sql: string, options?: {
|
|
15
|
-
is_verbose?: boolean;
|
|
16
13
|
}): Promise<{
|
|
17
14
|
[k: string]: unknown;
|
|
18
15
|
}[]>;
|
|
16
|
+
exec(sql: string, options?: {
|
|
17
|
+
is_verbose?: boolean;
|
|
18
|
+
}): Promise<any[]>;
|
|
19
19
|
get(table_id: string, primary_key: Record<string, any>, attribute_names?: string[], options?: {
|
|
20
20
|
is_verbose?: boolean;
|
|
21
|
-
}): Promise<Record<string, any
|
|
21
|
+
}): Promise<Record<string, any> | undefined>;
|
|
22
22
|
batch_get(table_id: string, primary_key: Record<string, any[]>, attribute_names?: string[], options?: {
|
|
23
23
|
is_verbose?: boolean;
|
|
24
|
-
}): Promise<
|
|
25
|
-
[k: string]: unknown;
|
|
26
|
-
}[]>;
|
|
24
|
+
}): Promise<any[]>;
|
|
27
25
|
create(table_id: string, item: Record<string, any>, options?: {
|
|
28
26
|
is_verbose?: boolean;
|
|
29
|
-
}): Promise<
|
|
30
|
-
[k: string]: unknown;
|
|
31
|
-
}[] | undefined>;
|
|
27
|
+
}): Promise<any[] | undefined>;
|
|
32
28
|
batch_create(table_id: string, items: Record<string, any>[], options?: {
|
|
33
29
|
is_verbose?: boolean;
|
|
34
|
-
}): Promise<
|
|
35
|
-
[k: string]: unknown;
|
|
36
|
-
}[] | undefined>;
|
|
30
|
+
}): Promise<any[] | undefined>;
|
|
37
31
|
put(table_id: string, item: Record<string, any>, options?: {
|
|
38
32
|
is_verbose?: boolean;
|
|
39
|
-
}): Promise<
|
|
40
|
-
[k: string]: unknown;
|
|
41
|
-
}[] | undefined>;
|
|
33
|
+
}): Promise<any[] | undefined>;
|
|
42
34
|
batch_put(table_id: string, items: Record<string, any>[], options?: {
|
|
43
35
|
is_verbose?: boolean;
|
|
44
|
-
}): Promise<
|
|
45
|
-
[k: string]: unknown;
|
|
46
|
-
}[] | undefined>;
|
|
36
|
+
}): Promise<any[] | undefined>;
|
|
47
37
|
delete(table_id: string, primary_key: Record<string, any>, options?: {
|
|
48
38
|
is_verbose?: boolean;
|
|
49
|
-
}): Promise<
|
|
50
|
-
[k: string]: unknown;
|
|
51
|
-
}[]>;
|
|
39
|
+
}): Promise<any[]>;
|
|
52
40
|
batch_delete(table_id: string, primary_key: Record<string, any[]>, options?: {
|
|
53
41
|
is_verbose?: boolean;
|
|
54
|
-
}): Promise<
|
|
55
|
-
[k: string]: unknown;
|
|
56
|
-
}[]>;
|
|
42
|
+
}): Promise<any[]>;
|
|
57
43
|
}
|
package/dist/src/UtilsRDS.js
CHANGED
|
@@ -46,10 +46,12 @@ export class UtilsRDS {
|
|
|
46
46
|
if (this.is_connected) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
+
this.is_connected = true;
|
|
49
50
|
return await this.postgres.connect();
|
|
50
51
|
}
|
|
51
52
|
async disconnect() {
|
|
52
|
-
|
|
53
|
+
await this.postgres.end();
|
|
54
|
+
this.is_connected = false;
|
|
53
55
|
}
|
|
54
56
|
async query(sql, options = {}) {
|
|
55
57
|
const is_verbose = Boolean(options.is_verbose);
|
|
@@ -63,7 +65,7 @@ export class UtilsRDS {
|
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
const response = await this.postgres.query(sql);
|
|
66
|
-
return response;
|
|
68
|
+
return response.rows.map(item => Object.fromEntries(Object.entries(item).filter(([key, value]) => value !== null)));
|
|
67
69
|
}
|
|
68
70
|
async exec(sql, options = {}) {
|
|
69
71
|
const is_verbose = Boolean(options.is_verbose);
|
|
@@ -79,6 +81,7 @@ export class UtilsRDS {
|
|
|
79
81
|
formatRecordsAs: "JSON"
|
|
80
82
|
})
|
|
81
83
|
.then(response => JSON.parse(response.formattedRecords || "[]"))
|
|
84
|
+
.then(items => items.map((item) => Object.fromEntries(Object.entries(item).filter(([key, value]) => value !== null))))
|
|
82
85
|
:
|
|
83
86
|
await this.query(sql, options);
|
|
84
87
|
if (!Array.isArray(items)) {
|
|
@@ -87,7 +90,7 @@ export class UtilsRDS {
|
|
|
87
90
|
}
|
|
88
91
|
return [];
|
|
89
92
|
}
|
|
90
|
-
return items
|
|
93
|
+
return items;
|
|
91
94
|
}
|
|
92
95
|
async get(table_id, primary_key, attribute_names, options = {}) {
|
|
93
96
|
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/dist/src/f.js
CHANGED
package/package.json
CHANGED
package/src/UtilsRDS.ts
CHANGED
|
@@ -54,11 +54,13 @@ export class UtilsRDS {
|
|
|
54
54
|
if (this.is_connected) {
|
|
55
55
|
return
|
|
56
56
|
}
|
|
57
|
+
this.is_connected = true
|
|
57
58
|
return await this.postgres.connect()
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
async disconnect() {
|
|
61
|
-
|
|
62
|
+
await this.postgres.end()
|
|
63
|
+
this.is_connected = false
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
async query(
|
|
@@ -78,7 +80,7 @@ export class UtilsRDS {
|
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
const response = await this.postgres.query(sql)
|
|
81
|
-
return response
|
|
83
|
+
return response.rows.map(item => Object.fromEntries(Object.entries(item).filter(([key, value]) => value !== null)))
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
async exec(
|
|
@@ -100,6 +102,7 @@ export class UtilsRDS {
|
|
|
100
102
|
formatRecordsAs : "JSON"
|
|
101
103
|
})
|
|
102
104
|
.then(response => JSON.parse(response.formattedRecords || "[]"))
|
|
105
|
+
.then(items => items.map((item : any) => Object.fromEntries(Object.entries(item).filter(([key, value]) => value !== null))))
|
|
103
106
|
:
|
|
104
107
|
await this.query(sql, options)
|
|
105
108
|
if (!Array.isArray(items)) {
|
|
@@ -108,7 +111,7 @@ export class UtilsRDS {
|
|
|
108
111
|
}
|
|
109
112
|
return []
|
|
110
113
|
}
|
|
111
|
-
return items
|
|
114
|
+
return items
|
|
112
115
|
}
|
|
113
116
|
|
|
114
117
|
async get(
|
package/src/f.ts
CHANGED