triangle-utils 1.4.78 → 1.4.79

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.
@@ -13,7 +13,9 @@ export declare class UtilsDynamoDB {
13
13
  max_num_items?: number;
14
14
  last_key?: Record<string, any>;
15
15
  }): Promise<Record<string, any>[]>;
16
- get(table: string, key: Record<string, any>, consistent?: boolean): Promise<Record<string, any> | undefined>;
16
+ get(table: string, key: Record<string, any>, options?: {
17
+ consistent?: boolean;
18
+ }): Promise<Record<string, any> | undefined>;
17
19
  get_max(table_index_name: string, primary_key: Record<string, string | number>): Promise<Record<string, any> | undefined>;
18
20
  query(table_index_name: string, primary_key: Record<string, any>, options?: {
19
21
  reverse?: boolean;
@@ -141,7 +141,8 @@ export class UtilsDynamoDB {
141
141
  const items = segments.flat().filter(is_item);
142
142
  return items;
143
143
  }
144
- async get(table, key, consistent = false) {
144
+ async get(table, key, options = {}) {
145
+ const consistent = options.consistent !== undefined ? options.consistent : false;
145
146
  const converted_key = convert_input(key)?.M;
146
147
  if (converted_key === undefined) {
147
148
  return undefined;
@@ -411,7 +412,7 @@ export class UtilsDynamoDB {
411
412
  this.dynamodb.updateItem(request);
412
413
  }
413
414
  async add(table_name, key, attributes) {
414
- const item = await this.get(table_name, key, true);
415
+ const item = await this.get(table_name, key, { consistent: true });
415
416
  if (item === undefined) {
416
417
  return;
417
418
  }
@@ -443,7 +444,7 @@ export class UtilsDynamoDB {
443
444
  await this.dynamodb.updateItem(request);
444
445
  }
445
446
  async create(table_name, key, attributes = {}) {
446
- const item = await this.get(table_name, key, true);
447
+ const item = await this.get(table_name, key, { consistent: true });
447
448
  if (item !== undefined) {
448
449
  return;
449
450
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.78",
3
+ "version": "1.4.79",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
@@ -169,8 +169,11 @@ export class UtilsDynamoDB {
169
169
  async get(
170
170
  table : string,
171
171
  key : Record<string, any>,
172
- consistent : boolean = false
172
+ options : {
173
+ consistent? : boolean
174
+ } = {}
173
175
  ) : Promise<Record<string, any> | undefined> {
176
+ const consistent = options.consistent !== undefined ? options.consistent : false
174
177
  const converted_key = convert_input(key)?.M
175
178
  if (converted_key === undefined) {
176
179
  return undefined
@@ -510,7 +513,7 @@ export class UtilsDynamoDB {
510
513
  }
511
514
 
512
515
  async add(table_name : string, key : Record<string, any>, attributes : Record<string, any[]>) : Promise<void> {
513
- const item = await this.get(table_name, key, true)
516
+ const item = await this.get(table_name, key, { consistent : true })
514
517
  if (item === undefined) {
515
518
  return
516
519
  }
@@ -546,7 +549,7 @@ export class UtilsDynamoDB {
546
549
  }
547
550
 
548
551
  async create(table_name : string, key : Record<string, any>, attributes : Record<string, any> = {}) : Promise<void> {
549
- const item = await this.get(table_name, key, true)
552
+ const item = await this.get(table_name, key, { consistent : true })
550
553
  if (item !== undefined) {
551
554
  return
552
555
  }