Get
Command to retrieve a single item by primary key from a DynamoDB table.
Example
Section titled “Example”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);Type Parameters
Section titled “Type Parameters”Schema
Section titled “Schema”Schema extends ZodObject
The Zod schema defining the structure of the entity.
Implements
Section titled “Implements”BaseCommand<GetResult<Schema>,Schema>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Get<Schema>(config): Get<Schema>;Parameters
Section titled “Parameters”config
Section titled “config”GetConfig<Schema>
Returns
Section titled “Returns”Get<Schema>
Methods
Section titled “Methods”execute()
Section titled “execute()”execute(entity): Promise<GetResult<Schema>>;Parameters
Section titled “Parameters”entity
Section titled “entity”DynamoEntity<Schema>
Returns
Section titled “Returns”Promise<GetResult<Schema>>