Skip to content

Update

Command to modify existing item attributes in a DynamoDB table.

import { DynamoTable, DynamoEntity, key, Update, add } 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(),
loginCount: z.number(),
}),
partitionKey: user => key('USER', user.userId),
sortKey: () => 'METADATA',
});
const updateCommand = new Update({
key: { userId: 'user123' },
update: {
name: 'Jane Doe',
loginCount: add(1),
},
returnValues: 'ALL_NEW',
});
const { updatedItem } = await userEntity.send(updateCommand);

Schema extends ZodObject

The Zod schema defining the structure of the entity.

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

UpdateConfig<Schema>

Update<Schema>

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

DynamoEntity<Schema>

Promise<UpdateResult<Schema>>

BaseCommand.execute


prepareWriteTransaction(entity): Promise<TransactWriteOperation>;

DynamoEntity<Schema>

Promise<TransactWriteOperation>

WriteTransactable.prepareWriteTransaction