triangle-utils 1.4.156 → 1.4.157
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 +2 -1
- package/dist/src/UtilsRDS.js +9 -3
- package/package.json +1 -1
- package/src/UtilsRDS.ts +10 -3
package/dist/src/UtilsRDS.d.ts
CHANGED
|
@@ -27,7 +27,8 @@ export declare class UtilsRDS {
|
|
|
27
27
|
is_verbose?: boolean;
|
|
28
28
|
is_forced?: boolean;
|
|
29
29
|
}): Promise<Record<string, any> | undefined>;
|
|
30
|
-
batch_get(table_id: string,
|
|
30
|
+
batch_get(table_id: string, primary_keys: Record<string, any>[], options?: {
|
|
31
|
+
batch_num_items?: number;
|
|
31
32
|
attribute_names?: string[];
|
|
32
33
|
is_verbose?: boolean;
|
|
33
34
|
is_forced?: boolean;
|
package/dist/src/UtilsRDS.js
CHANGED
|
@@ -140,9 +140,15 @@ export class UtilsRDS {
|
|
|
140
140
|
const item = items[0];
|
|
141
141
|
return item;
|
|
142
142
|
}
|
|
143
|
-
async batch_get(table_id,
|
|
144
|
-
const
|
|
145
|
-
const
|
|
143
|
+
async batch_get(table_id, primary_keys, options = {}) {
|
|
144
|
+
const batch_num_items = options.batch_num_items || 100;
|
|
145
|
+
const attribute_names = Array.from(new Set(primary_keys.map(primary_key => Object.keys(primary_key)).flat())).sort();
|
|
146
|
+
const items = [];
|
|
147
|
+
for (let i = 0; i < primary_keys.length; i += batch_num_items) {
|
|
148
|
+
const sql = "SELECT " + (options.attribute_names === undefined ? "*" : options.attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + "(" + attribute_names.join(", ") + ")" + " IN " + "(" + primary_keys.map(primary_key => "(" + attribute_names.map(attribute_name => convert_rds_input(primary_key[attribute_name])).join(", ") + ")").join(", ") + ")";
|
|
149
|
+
const new_items = await this.exec(sql, options);
|
|
150
|
+
items.push(...new_items);
|
|
151
|
+
}
|
|
146
152
|
return items;
|
|
147
153
|
}
|
|
148
154
|
async create(table_id, item, options = {}) {
|
package/package.json
CHANGED
package/src/UtilsRDS.ts
CHANGED
|
@@ -185,15 +185,22 @@ export class UtilsRDS {
|
|
|
185
185
|
|
|
186
186
|
async batch_get(
|
|
187
187
|
table_id : string,
|
|
188
|
-
|
|
188
|
+
primary_keys : Record<string, any>[],
|
|
189
189
|
options : {
|
|
190
|
+
batch_num_items? : number,
|
|
190
191
|
attribute_names? : string[],
|
|
191
192
|
is_verbose? : boolean,
|
|
192
193
|
is_forced? : boolean
|
|
193
194
|
} = {}
|
|
194
195
|
) {
|
|
195
|
-
const
|
|
196
|
-
const
|
|
196
|
+
const batch_num_items = options.batch_num_items || 100
|
|
197
|
+
const attribute_names = Array.from(new Set(primary_keys.map(primary_key => Object.keys(primary_key)).flat())).sort()
|
|
198
|
+
const items = []
|
|
199
|
+
for (let i = 0; i < primary_keys.length; i += batch_num_items) {
|
|
200
|
+
const sql = "SELECT " + (options.attribute_names === undefined ? "*" : options.attribute_names.join(", ")) + " FROM " + table_id + " WHERE " + "(" + attribute_names.join(", ") + ")" + " IN " + "(" + primary_keys.map(primary_key => "(" + attribute_names.map(attribute_name => convert_rds_input(primary_key[attribute_name])).join(", ") + ")" ).join(", ") + ")"
|
|
201
|
+
const new_items = await this.exec(sql, options)
|
|
202
|
+
items.push(...new_items)
|
|
203
|
+
}
|
|
197
204
|
return items
|
|
198
205
|
}
|
|
199
206
|
|