Interfaces
KeySchema
Defined in: dynamo-db/get-item.ts:8
Key schema for DynamoDB item retrieval.
Properties
pk
pk:
string
Defined in: dynamo-db/get-item.ts:10
Partition key value
sk?
optionalsk:string
Defined in: dynamo-db/get-item.ts:12
Optional sort key value
Functions
getItem()
getItem(
keys,tableName,maxIterations?,delayInSeconds?):Promise<Record<string,string|number|boolean|object>>
Defined in: dynamo-db/get-item.ts:41
Retrieves an item from a DynamoDB table with automatic retry logic.
Useful for E2E and integration tests where you need to verify that a record has been created in DynamoDB after triggering an async flow. The function will poll the table until the item is found or max retries are exhausted.
Parameters
keys
The partition key (and optional sort key) to look up
tableName
string
The name of the DynamoDB table
maxIterations?
number = 10
Maximum number of retry attempts (default: 10)
delayInSeconds?
number = 2
Delay between retry attempts in seconds (default: 2)
Returns
Promise<Record<string, string | number | boolean | object>>
The retrieved DynamoDB item
Throws
Error if the record is not found after all retry attempts
Example
// Wait for a record to appear after triggering an async process
const item = await getItem(
{ pk: 'USER#123', sk: 'PROFILE' },
'my-table',
15, // max 15 attempts
3 // 3 seconds between attempts
);
expect(item.status).toBe('ACTIVE');