Skip to content

Get

Command to retrieve a single item by primary key from a DynamoDB table.

import { DynamoTable, DynamoEntity, key, Get } 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(),
email: z.string(),
}),
partitionKey: user => key('USER', user.userId),
sortKey: () => 'METADATA',
});
const getCommand = new Get({
key: { userId: 'user123' },
consistent: true,
});
const { item } = await userEntity.send(getCommand);

Schema extends ZodObject

The Zod schema defining the structure of the entity.

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

GetConfig<Schema>

Get<Schema>

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

DynamoEntity<Schema>

Promise<GetResult<Schema>>

BaseCommand.execute