Skip to content

ProjectedScan

Command to scan entire table or index and retrieve specific attributes (expensive operation).

The Zod schema defining the structure of the projected attributes.

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);

Schema extends ZodObject

The Zod schema defining the structure of the entity.

ProjectedSchema extends ZodObject

new ProjectedScan<Schema, ProjectedSchema>(config): ProjectedScan<Schema, ProjectedSchema>;

ProjectedScanConfig<ProjectedSchema>

ProjectedScan<Schema, ProjectedSchema>

buildCommandInput(entity): ScanCommandInput;

DynamoEntity<Schema>

ScanCommandInput


buildResult(items, scanResult): ProjectedScanResult<Schema, ProjectedSchema>;

EntitySchema<ProjectedSchema>[]

ScanCommandOutput

ProjectedScanResult<Schema, ProjectedSchema>


execute(entity): Promise<ProjectedScanResult<Schema, ProjectedSchema>>;

DynamoEntity<Schema>

Promise<ProjectedScanResult<Schema, ProjectedSchema>>

BaseCommand.execute


executePaginated(entity): AsyncGenerator<ProjectedScanResult<Schema, ProjectedSchema>, void, unknown>;

DynamoEntity<Schema>

AsyncGenerator<ProjectedScanResult<Schema, ProjectedSchema>, void, unknown>

BasePaginatable.executePaginated


validateItems(items): Promise<EntitySchema<ProjectedSchema>[]>;

Record<string, any>[] | undefined

Promise<EntitySchema<ProjectedSchema>[]>