Skip to main content

TransactionConstraint TypeAlias

A requirement for a SharedTree transaction to succeed.

Signature

export type TransactionConstraint = NodeInDocumentConstraint;

Remarks

Transaction constraints are useful for validating that the state of the tree meets some requirement when a transaction runs. In general, when running a transaction a client can validate their tree state in whatever way they wish and decide to either proceed with the transaction or not. However, they cannot know what the tree state will be when the transaction is _sequenced_. There may have been any number of edits from other clients that get sequenced before the transaction is eventually sequenced. Constraints provide a way to validate the tree state after the transaction has been sequenced and abort the transaction if the constraints are not met. All clients will validate the constraints of a transaction when it is sequenced, so all clients will agree on whether the transaction succeeds or not.