UpdateItem
Store.update()
Create a update query.
import { DynamoDBClient } from '@aws-cdk/client-dynamodb'
import { Store } from '@declanprice/dynostore'
const store = new Store('customers', new new DynamoDBClient())
const request = await store.update<CustomerItem>();
key(key)
Provide the item key to update.
request.key({ id: customer.id });
update(...conditions)
Provide one or more update conditions.
request.update(
set('name', 'declan'),
increment('age', 1),
);
condition(...conditions)
Provide any combination of supported dynamodb conditions, multiple conditions must be seperated by either and()
, or()
conditions otherwise an error will be thrown.
request.condition(
eq('name', 'declan'),
and(),
gt('age', 22)
);
return(returnValue)
Provide return value from of the response.
request.return('ALL_NEW')
exec()
Execute the request.
The response will either be the return
value specified, or null.
const oldCustomer: Customer | null = await request.exec();
tx()
Create a TransactUpdateItem.
const updateCustomerTxItem = request.tx()