triangle-utils 1.0.15 → 1.0.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "main": "index.js",
5
5
  "author": "",
6
6
  "license": "ISC",
package/utils/dynamodb.js CHANGED
@@ -204,7 +204,7 @@ export async function dynamodb_append(clients, table, key, attributes) {
204
204
  }
205
205
 
206
206
  export async function dynamodb_add(clients, table, key, attributes) {
207
- const item = await get(table, key, true)
207
+ const item = await dynamodb_get(clients, table, key, true)
208
208
  const new_attributes = {}
209
209
  for (const [attribute, values] of Object.entries(attributes)) {
210
210
  if (item[attribute] === undefined) {
@@ -218,7 +218,7 @@ export async function dynamodb_add(clients, table, key, attributes) {
218
218
  if (Object.values(new_attributes).flat().length === 0) {
219
219
  return undefined
220
220
  }
221
- return await append(table, key, attributes)
221
+ return await dynamodb_append(clients, table, key, attributes)
222
222
  }
223
223
 
224
224
  export async function dynamodb_remove(clients, table, key, attributes) {
@@ -234,7 +234,7 @@ export async function dynamodb_remove(clients, table, key, attributes) {
234
234
  }
235
235
 
236
236
  export async function dynamodb_create(clients, table, key, attributes = {}) {
237
- const item = await get(table, key)
237
+ const item = await dynamodb_get(clients, table, key)
238
238
  if (item !== undefined) {
239
239
  return undefined
240
240
  }
@@ -255,7 +255,7 @@ export async function dynamodb_duplicate_attribute(clients, table, attribute_nam
255
255
  const table_key_names = await clients.dynamodb.describeTable({
256
256
  TableName : table
257
257
  }).then(metadata => metadata.Table.KeySchema.map(key => key.AttributeName))
258
- const items = await scan(table, table_key_names.concat([attribute_name, new_attribute_name]))
258
+ const items = await dynamodb_scan(clients, table, table_key_names.concat([attribute_name, new_attribute_name]))
259
259
  if (items.filter(item => item[new_attribute_name] !== undefined).length > 0) {
260
260
  console.log("Cannot rename.", new_attribute_name, "is an existing item.")
261
261
  return
@@ -265,7 +265,7 @@ export async function dynamodb_duplicate_attribute(clients, table, attribute_nam
265
265
  continue
266
266
  }
267
267
  const key = Object.fromEntries(table_key_names.map(key_name => [key_name, item[key_name]]))
268
- await set(table, key, { [new_attribute_name] : item[attribute_name] })
268
+ await dynamodb_set(clients, table, key, { [new_attribute_name] : item[attribute_name] })
269
269
  }
270
270
  }
271
271
 
@@ -273,10 +273,10 @@ export async function dynamodb_remove_attribute(clients, table, attribute_name)
273
273
  const table_key_names = await clients.dynamodb.describeTable({
274
274
  TableName : table
275
275
  }).then(metadata => metadata.Table.KeySchema.map(key => key.AttributeName))
276
- const items = await scan(table)
276
+ const items = await dynamodb_scan(clients, table)
277
277
  .then(items => items.filter(item => item[attribute_name] !== undefined))
278
278
  for (const item of items) {
279
279
  const key = Object.fromEntries(table_key_names.map(key_name => [key_name, item[key_name]]))
280
- await remove(table, key, [attribute_name])
280
+ await dynamodb_remove(clients, table, key, [attribute_name])
281
281
  }
282
282
  }