triangle-utils 1.4.147 → 1.4.148

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.
@@ -38,4 +38,7 @@ export declare class UtilsRDS {
38
38
  batch_delete(table_id: string, primary_key: Record<string, any[]>, options?: {
39
39
  is_verbose?: boolean;
40
40
  }): Promise<any[]>;
41
+ set(table_id: string, primary_key: Record<string, any>, attributes: Record<string, any>, options?: {
42
+ is_verbose?: boolean;
43
+ }): Promise<any[]>;
41
44
  }
@@ -192,4 +192,9 @@ export class UtilsRDS {
192
192
  const sql = "DELETE FROM " + table_id + " WHERE " + Object.entries(primary_key).map(([key_name, values]) => key_name + " IN " + "(" + values.map(value => convert_rds_input(value)).join(", ") + ")").join(" AND ");
193
193
  return await this.exec(sql, options);
194
194
  }
195
+ async set(table_id, primary_key, attributes, options = {}) {
196
+ const attribute_names = Object.keys(attributes).sort();
197
+ const sql = "UPDATE " + table_id + " SET " + attribute_names.map(attribute_name => attribute_name + " = " + convert_rds_input(attributes[attribute_name])).join(", ") + " WHERE " + Object.entries(primary_key).map(([key_name, value]) => key_name + " = " + convert_rds_input(value)).join(" AND ");
198
+ return await this.exec(sql, options);
199
+ }
195
200
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.147",
3
+ "version": "1.4.148",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/UtilsRDS.ts CHANGED
@@ -267,6 +267,18 @@ export class UtilsRDS {
267
267
  return await this.exec(sql, options)
268
268
  }
269
269
 
270
+ async set(
271
+ table_id : string,
272
+ primary_key : Record<string, any>,
273
+ attributes : Record<string, any>,
274
+ options : {
275
+ is_verbose? : boolean
276
+ } = {}
277
+ ) {
278
+ const attribute_names = Object.keys(attributes).sort()
279
+ const sql = "UPDATE " + table_id + " SET " + attribute_names.map(attribute_name => attribute_name + " = " + convert_rds_input(attributes[attribute_name])).join(", ") + " WHERE " + Object.entries(primary_key).map(([key_name, value]) => key_name + " = " + convert_rds_input(value)).join(" AND ")
280
+ return await this.exec(sql, options)
281
+ }
270
282
 
271
283
 
272
284
  }