ConditionCheck
Command to verify a condition without modifying data in a transaction.
Example
Section titled “Example”import { DynamoTable, DynamoEntity, key, TransactWrite, ConditionCheck, Update } from 'dynamo-document-builder';
const table = new DynamoTable({ tableName: 'ExampleTable', documentClient,});
const userEntity = new DynamoEntity({ table, schema: z.object({ userId: z.string(), balance: z.number(), }), partitionKey: user => key('USER', user.userId), sortKey: () => 'METADATA',});
const transactWriteCommand = new TransactWrite({ writes: [ new ConditionCheck({ key: { userId: 'user1' }, condition: { balance: greaterThan(100) }, }), new Update({ key: { userId: 'user2' }, update: { balance: add(50) } }), ],});
await userEntity.send(transactWriteCommand);Type Parameters
Section titled “Type Parameters”Schema
Section titled “Schema”Schema extends ZodObject
The Zod schema defining the structure of the entity.
Implements
Section titled “Implements”WriteTransactable<Schema>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ConditionCheck<Schema>(config): ConditionCheck<Schema>;Parameters
Section titled “Parameters”config
Section titled “config”ConditionCheckConfig<Schema>
Returns
Section titled “Returns”ConditionCheck<Schema>
Methods
Section titled “Methods”prepareWriteTransaction()
Section titled “prepareWriteTransaction()”prepareWriteTransaction(entity): Promise<TransactWriteOperation>;Parameters
Section titled “Parameters”entity
Section titled “entity”DynamoEntity<Schema>
Returns
Section titled “Returns”Promise<TransactWriteOperation>