BatchWriteItem

The BatchWriteItem operation puts or deletes multiple items in one table.

Source:
See:

Methods

(inner) batchInsertFor(tableName, items) → {Promise}

Source:

Returns a function that puts items in a table in a single batch. It expects an array of arbitrary items to insert in tableName. It also supports inserting a single element (i.e.: not passing in an array). You would typically use this function through forTable.

Examples
// Inserts two items in `SomeTable`
 await batchInsertFor('SomeTable')([{ foo: 'bar' }, { foo: 'baz' }]);
// Exported from `forTable`
 const { batchInsert } = forTable('SomeTable');
 batchInsert([{ foo: 'bar' }, { foo: 'baz' }]);
Parameters:
Name Type Description
tableName string

The name of the DynamoDB table to run the query on

items Array.<Object> | Object

Items to insert into tableName

Returns:

Resolves to the response from DynamoDB client.

Type
Promise

(inner) batchRemoveFor(tableName, keys) → {Promise}

Source:

Returns a function that deletes multiple items from a table in a single batch. It expects an array of Key values to delete. If no name is specified for the Key, a name of id will be assumed. You would typically use this function through forTable.

Examples
// Removes a document with Key `{ foo: 'bar' }`
 await batchRemoveFor('SomeTable')([{ Key: { foo: 'bar' } }]);
// Removes three documents with Keys `{id: 33}`, `{id: 42}` and `{id: 7}`
 await batchRemoveFor('SomeTable')([33, 42, 7]);
// Exported from `forTable`
 const { batchRemove } = forTable('SomeTable');
 await batchRemove([33, 42, 7]);
Parameters:
Name Type Description
tableName string

The name of the DynamoDB table to run the query on

keys Array.<*> | *

Identifiers of elements to delete from tableName

Returns:

Resolves to the response from DynamoDB client.

Type
Promise

(inner) batchWriteFor(tableName, items) → {Promise}

Source:

Returns a function that puts or deletes multiple items in a table. It expects a single object argument containing insert and/or remove array properties. Each describe items that will be inserted or deleted from tableName. Each element in these arrays can be thought of as inputs to corresponding insert or remove Flynamo functions. You would typically use this function through forTable.

Examples
// Inserts two items in `SomeTable`
 await batchWriteFor('SomeTable')({ insert: [{ foo: 'bar' }, { foo: 'baz' }] });
// Inserts one item and remove item with Key 42 in `SomeTable`
 await batchWriteFor('SomeTable')({ insert: [{ foo: 'bar' }], remove: [42] });
// Exported from `forTable`
 const { batchWrite } = forTable('SomeTable');
 await batchWrite({ insert: [{ foo: 'bar' }], remove: [42] });
Parameters:
Name Type Description
tableName string

The name of the DynamoDB table to run the query on

items Object

An object containing insert and/or remove properties.

Returns:

Resolves to the response from DynamoDB client.

Type
Promise