The BatchGetItem
operation retrieves multiple items from a table in a single call.
Methods
(inner) batchGetFor(tableName, keys) → {Promise}
- Source:
Returns the attributes of one or more items from a table. Requested items are identified by primary key.
A key represented by a Number
or a String
will be assumed to be named id
.
Items will be fetched from tableName
. You would typically use this function through forTable
.
Examples
// Fetch documents of `id` 42, 33 and 7
await batchGetFor('SomeTable')([42, 33, 7]);
// Fetch documents of keys `{ foo: 42 }` and `{ foo: 33 }`
await batchGetFor('SomeTable')([{ foo: 42 }, { foo: 33 }]);
// Retrieve only `name` and `age` fields
await batchGetFor('SomeTable')([42, 33], { ProjectionExpression: 'name, age' });
// Exported from `forTable`
const { batchGet } = forTable('SomeTable');
await batchGet([42, 33, 7]);
Parameters:
Name | Type | Description |
---|---|---|
tableName |
string | The name of the DynamoDB table to run the query on |
keys |
Array.<*> | * | Identifiers of elements to get from |
Returns:
Resolves to the response from DynamoDB client.
- Type
- Promise