Each statement within SurrealDB is run within its own transaction by default. If a set of changes need to be made together, then groups of statements can be run together as a single transaction, either succeeding as a whole, or failing without leaving any residual data modifications. A COMMIT statement is used at the end of such a transaction to make the data modifications a permanent part of the database.
Statement syntax
SurrealQL Syntax
COMMIT[TRANSACTION];
Example usage
The following query shows example usage of this statement.
THROW to cancel a transaction with an optional error message. THROW is the only way to cancel a transaction based on a condition, such as inside an IF..ELSE block.
In addition, a RETURN statement can be used to return early from a successful transaction. This is often used in order to return a customized output.