ProjectedScan
Command to scan entire table or index and retrieve specific attributes (expensive operation).
Template
Section titled “Template”The Zod schema defining the structure of the projected attributes.
Example
Section titled “Example”import { DynamoTable, DynamoEntity, key, ProjectedScan } from 'dynamo-document-builder';
const table = new DynamoTable({ tableName: 'ExampleTable', documentClient,});
const todoEntity = new DynamoEntity({ table, schema: z.object({ userId: z.string(), todoId: z.string(), title: z.string(), description: z.string(), isComplete: z.boolean(), }), partitionKey: todo => key('USER', todo.userId), sortKey: todo => key('TODO', todo.todoId),});
const projectedScanCommand = new ProjectedScan({ projection: ['title', 'isComplete'], projectionSchema: z.object({ title: z.string(), isComplete: z.boolean(), }), filter: { isComplete: false }, limit: 100,});
const { items, scannedCount } = await todoEntity.send(projectedScanCommand);Type Parameters
Section titled “Type Parameters”Schema
Section titled “Schema”Schema extends ZodObject
The Zod schema defining the structure of the entity.
ProjectedSchema
Section titled “ProjectedSchema”ProjectedSchema extends ZodObject
Implements
Section titled “Implements”BaseCommand<ProjectedScanResult<Schema,ProjectedSchema>,Schema>BasePaginatable<ProjectedScanResult<Schema,ProjectedSchema>,Schema>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ProjectedScan<Schema, ProjectedSchema>(config): ProjectedScan<Schema, ProjectedSchema>;Parameters
Section titled “Parameters”config
Section titled “config”ProjectedScanConfig<ProjectedSchema>
Returns
Section titled “Returns”ProjectedScan<Schema, ProjectedSchema>
Methods
Section titled “Methods”buildCommandInput()
Section titled “buildCommandInput()”buildCommandInput(entity): ScanCommandInput;Parameters
Section titled “Parameters”entity
Section titled “entity”DynamoEntity<Schema>
Returns
Section titled “Returns”ScanCommandInput
buildResult()
Section titled “buildResult()”buildResult(items, scanResult): ProjectedScanResult<Schema, ProjectedSchema>;Parameters
Section titled “Parameters”EntitySchema<ProjectedSchema>[]
scanResult
Section titled “scanResult”ScanCommandOutput
Returns
Section titled “Returns”ProjectedScanResult<Schema, ProjectedSchema>
execute()
Section titled “execute()”execute(entity): Promise<ProjectedScanResult<Schema, ProjectedSchema>>;Parameters
Section titled “Parameters”entity
Section titled “entity”DynamoEntity<Schema>
Returns
Section titled “Returns”Promise<ProjectedScanResult<Schema, ProjectedSchema>>
Implementation of
Section titled “Implementation of”executePaginated()
Section titled “executePaginated()”executePaginated(entity): AsyncGenerator<ProjectedScanResult<Schema, ProjectedSchema>, void, unknown>;Parameters
Section titled “Parameters”entity
Section titled “entity”DynamoEntity<Schema>
Returns
Section titled “Returns”AsyncGenerator<ProjectedScanResult<Schema, ProjectedSchema>, void, unknown>
Implementation of
Section titled “Implementation of”BasePaginatable.executePaginated
validateItems()
Section titled “validateItems()”validateItems(items): Promise<EntitySchema<ProjectedSchema>[]>;Parameters
Section titled “Parameters”Record<string, any>[] | undefined
Returns
Section titled “Returns”Promise<EntitySchema<ProjectedSchema>[]>