Multi operations and Transactions
Crecto provides the Multi
class, for utilizing database transactions.
With Multi
, if any step of the transaction fails then all changes are rolled back.
As with Query
, its easiest to create a shortcut variable.
Multi
example and methods
First create the multi intance
Build the multi with the needed database operations
Insert the multi using your Repo
Check the multi for errors. If there were errors on any of the operations, then none of the operations will be persisted.