Skip to content

Scan

Command to scan entire table or index (expensive operation).

import { DynamoTable, DynamoEntity, key, Scan } 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(),
isComplete: z.boolean(),
}),
partitionKey: todo => key('USER', todo.userId),
sortKey: todo => key('TODO', todo.todoId),
});
const scanCommand = new Scan({
filter: { isComplete: false },
limit: 100,
});
const { items, scannedCount } = await todoEntity.send(scanCommand);

Schema extends ZodObject

The Zod schema defining the structure of the entity.

new Scan<Schema>(config?): Scan<Schema>;

ScanConfig<Schema>

Scan<Schema>

buildCommandInput(entity): ScanCommandInput;

DynamoEntity<Schema>

ScanCommandInput


buildResult(items, scanResult): ScanResult<Schema>;

EntitySchema<Schema>[]

ScanCommandOutput

ScanResult<Schema>


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

DynamoEntity<Schema>

Promise<ScanResult<Schema>>

BaseCommand.execute


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

DynamoEntity<Schema>

AsyncGenerator<ScanResult<Schema>, void, unknown>

BasePaginatable.executePaginated


validateItems(entity, items): Promise<EntitySchema<Schema>[]>;

DynamoEntity<Schema>

Record<string, any>[] | undefined

Promise<EntitySchema<Schema>[]>