GetItem

The GetItem operation returns a set of attributes for the item with the given primary key.

Source:
See:

Methods

(inner) get(key, request) → {Promise}

Source:
See:

Returns a set of attributes for the item with the given primary key. If there is no matching item, it returns undefined. The name of the key defaults to id if it's not specified. The Key attribute (as expected by DynamoDB request) can be omitted.

Examples
await get(42, { TableName: 'SomeTable' });
 // Will return the item with an primary key of `{id: 42}` from `SomeTable`
await get({ customId: 'foo' }, { TableName: 'SomeTable' });
 // Will return the item with an primary key of `{customId: 'foo'}` from `SomeTable`
await get({ Key: { id: 42 } }, { TableName: 'SomeTable' });
 // Will return the item with an primary key of `{id: 42}` from `SomeTable`
Parameters:
Name Type Description
key *

The primary key value.

request Object

Parameters as expected by DynamoDB GetItem operation. Any Key attribute specified here will override primary key value in key.

Returns:

A promise that resolves to the item returned by DynamoDB response or undefined if it does not exist.

Type
Promise

(inner) getFor(tableName, key, requestopt) → {Promise}

Source:
See:

Returns a function that returns a set of attributes for the item with the given primary key. If there is no matching item, it returns undefined. The name of the key defaults to id if it's not specified. The Key attribute (as expected by DynamoDB request) can be omitted. The last request argument is optional and is only required if any non mandatory attribute needs to be included in the request. You would typically use this function through forTable.

Examples
await getFor('TableName')(42);
 // Will return the item with an primary key of `{id: 42}` from `SomeTable`
await getFor('SomeTable')({ customId: 'foo' });
 // Will return the item with an primary key of `{customId: 'foo'}` from `SomeTable`
await getFor('SomeTable')({ Key: { id: 42 } });
 // Will return the item with an primary key of `{id: 42}` from `SomeTable`
Parameters:
Name Type Attributes Description
tableName String

The name of the table to perform the operation on

key *

The primary key value.

request Object <optional>

Parameters as expected by DynamoDB GetItem operation (optional). Any Key or TableName attributes specified here will override primary key value in key or tableName arguments.

Returns:

A promise that resolves to the item returned by DynamoDB response or undefined if it does not exist.

Type
Promise