ProjectedGet
Command to retrieve specific attributes of a single item by primary key.
Example
Section titled “Example”import { DynamoTable, DynamoEntity, key, ProjectedGet } 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(), age: z.number(), }), partitionKey: user => key('USER', user.userId), sortKey: () => 'METADATA',});
const projectedGetCommand = new ProjectedGet({ key: { userId: 'user123' }, projection: ['name', 'email'], projectionSchema: z.object({ name: z.string(), email: z.string(), }), consistent: true,});
const { item } = await userEntity.send(projectedGetCommand);Type Parameters
Section titled “Type Parameters”Schema
Section titled “Schema”Schema extends ZodObject
The Zod schema defining the structure of the entity.
ProjectionSchema
Section titled “ProjectionSchema”ProjectionSchema extends ZodObject
The Zod schema defining the structure of the projected attributes.
Implements
Section titled “Implements”BaseCommand<ProjectedGetResult<ProjectionSchema>,Schema>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ProjectedGet<Schema, ProjectionSchema>(config): ProjectedGet<Schema, ProjectionSchema>;Parameters
Section titled “Parameters”config
Section titled “config”ProjectedGetConfig<Schema, ProjectionSchema>
Returns
Section titled “Returns”ProjectedGet<Schema, ProjectionSchema>
Methods
Section titled “Methods”execute()
Section titled “execute()”execute(entity): Promise<ProjectedGetResult<ProjectionSchema>>;Parameters
Section titled “Parameters”entity
Section titled “entity”DynamoEntity<Schema>
Returns
Section titled “Returns”Promise<ProjectedGetResult<ProjectionSchema>>