Skip to content

Put

Command to create or replace an item in a DynamoDB table.

import { DynamoTable, DynamoEntity, key, Put } 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(),
email: z.string(),
}),
partitionKey: user => key('USER', user.userId),
sortKey: () => 'METADATA',
});
const putCommand = new Put({
item: {
userId: 'user123',
name: 'John Doe',
email: 'john@example.com',
},
returnValues: 'ALL_OLD',
});
const { returnItem } = await userEntity.send(putCommand);

Schema extends ZodObject

The Zod schema defining the structure of the entity.

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

PutConfig<Schema>

Put<Schema>

buildItem(entity): Promise<
| output<Schema> & DynamoKey
| input<Schema> & DynamoKey>;

DynamoEntity<Schema>

Promise< | output<Schema> & DynamoKey | input<Schema> & DynamoKey>


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

DynamoEntity<Schema>

Promise<PutResult<Schema>>

BaseCommand.execute


prepareWriteTransaction(entity): Promise<TransactWriteOperation>;

DynamoEntity<Schema>

Promise<TransactWriteOperation>

WriteTransactable.prepareWriteTransaction