Skip to content

TableBatchGet

Table-level command to perform a batch get across multiple entity types.

Unlike BatchGet which operates on a single entity type, this command accepts get operations from multiple entities via entity.prepare(new BatchGet({ keys: [...] })) and returns results grouped by entity in a tuple structure.

Unprocessed keys are returned per entity in a tuple matching the input order.

const { items, unprocessedKeys } = await table.send(new TableBatchGet({
gets: [
userEntity.prepare(new BatchGet({
keys: [{ userId: 'u1' }, { userId: 'u2' }],
})),
orderEntity.prepare(new BatchGet({
keys: [{ orderId: 'o1' }],
})),
],
consistent: true, // Apply strongly consistent reads to all groups
}))
const [users, orders] = items
// users: User[]
// orders: Order[]

Gets extends PreparedBatchGet<any>[]

new TableBatchGet<Gets>(config): TableBatchGet<Gets>;

TableBatchGetConfig<Gets>

TableBatchGet<Gets>

execute(table): Promise<TableBatchGetResult<Gets>>;

DynamoTable

Promise<TableBatchGetResult<Gets>>

TableCommand.execute