BatchPutRequest
Builds a request to put an entity item, to be used within BatchWriteCommands
:
import { BatchPutRequest } from 'dynamodb-toolbox/entity/actions/batchPut'
const request = PokemonEntity.build(BatchPutRequest)
const params = request.params()
Request
.item(...)
(required)
The item to write:
const request = PokemonEntity.build(BatchPutRequest).item({
pokemonId: 'pikachu1',
name: 'Pikachu',
pokeType: 'electric',
level: 50,
...
})
You can use the PutItemInput
type from the PutItemCommand
action to explicitly type an object as a BatchPutRequest
item object:
import type { PutItemInput } from 'dynamodb-toolbox/entity/actions/put'
const item: PutItemInput<typeof PokemonEntity> = {
pokemonId: 'pikachu1',
name: 'Pikachu',
...
}
const request =
PokemonEntity.build(BatchPutRequest).item(item)
info
Contrary to PutItemCommands
, batch writes cannot be conditioned, nor return the previous values of the written items.