Skip to content

TransactGet

Command to perform a transactional read of multiple items (all-or-nothing, strongly consistent).

import { DynamoTable, DynamoEntity, key, TransactGet } 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(),
}),
partitionKey: user => key('USER', user.userId),
sortKey: () => 'METADATA',
});
const transactGetCommand = new TransactGet({
keys: [
{ userId: 'user1' },
{ userId: 'user2' },
],
});
const { items } = await userEntity.send(transactGetCommand);
// items array has same order as keys, undefined if not found

Schema extends ZodObject

The Zod schema defining the structure of the entity.

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

TransactGetConfig<Schema>

TransactGet<Schema>

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

DynamoEntity<Schema>

Promise<TransactGetResult<Schema>>

BaseCommand.execute