Skip to content

Delete

Command to remove an item from a DynamoDB table.

import { DynamoTable, DynamoEntity, key, Delete } 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(),
}),
partitionKey: user => key('USER', user.userId),
sortKey: () => 'METADATA',
});
const deleteCommand = new Delete({
key: { userId: 'user123' },
returnValues: 'ALL_OLD',
});
const { deletedItem } = await userEntity.send(deleteCommand);

Schema extends ZodObject

The Zod schema defining the structure of the entity.

new Delete<Schema>(config): Delete<Schema>;

DeleteConfig<Schema>

Delete<Schema>

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

DynamoEntity<Schema>

Promise<DeleteResult<Schema>>

BaseCommand.execute


prepareWriteTransaction(entity): Promise<TransactWriteOperation>;

DynamoEntity<Schema>

Promise<TransactWriteOperation>

WriteTransactable.prepareWriteTransaction