Skip to content

BatchGet

Command to perform a batch get operation on a DynamoDB table.

import { DynamoTable, DynamoEntity, key, BatchGet } from 'dynamo-document-builder';
const table = new DynamoTable({
tableName: 'ExampleTable',
documentClient,
});
const userEntity = new DynamoEntity({
table,
schema: z.object({
userId: z.string(),
name: z.string(),
age: z.number(),
}),
partitionKey: user => key('USER', user.userId),
sortKey: () => 'USER',
});
const batchGetCommand = new BatchGet({
keys: [
{ userId: 'user1' },
{ userId: 'user2' },
],
consistent: true,
});
const { items } = await batchGetCommand.execute(userEntity);

Schema extends ZodObject

The Zod schema defining the structure of the entity.

new BatchGet<Schema>(config): BatchGet<Schema>;

BatchGetConfig<Schema>

BatchGet<Schema>

execute(entity): Promise<BatchGetResult<Schema>>;

DynamoEntity<Schema>

Promise<BatchGetResult<Schema>>

BaseCommand.execute