ConnectionManager::transaction() runs a set of ORM queries inside one transaction. It passes a transaction executor to your callback; run your queries through that executor with withExecutor() or the executor: argument. The transaction commits when the callback returns, and rolls back if it throws.
If the callback throws, the transaction is rolled back and the exception is rethrown, so the batch either applies in full or not at all.
Note
Validation and errors
Surqlize validates several contracts before it builds or executes a query, and raises typed exceptions when they fail.
Model classes must extend
Surqlize\Model\Model, and edge classes must extendSurqlize\Edge\Edge.Table and field identifiers are validated before compilation.
findOrFail()throwsSurqlize\Model\Exception\ModelNotFoundExceptionwhen no record matches.Schema validation rules run before
create()andsave(), and a failing rule raises aValidationException.Persistence methods throw when a required
RecordIdis missing.RELATEvalidates the edge endpoint classes and their record ids.
Learn more
Connections for executor injection
Mutations for the queries you batch
Transactions in the SDK for the underlying mechanism