Skip to content

Commit

Permalink
fix: improve transaction description correctness.
Browse files Browse the repository at this point in the history
  • Loading branch information
SandPod committed Dec 12, 2024
1 parent 3c03ba0 commit 1f4d501
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/06-concepts/06-database/08-transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

The essential point of a database transaction is that it bundles multiple steps into a single, all-or-nothing operation. The intermediate states between the steps are not visible to other concurrent transactions, and if some failure occurs that prevents the transaction from completing, then none of the steps affect the database at all.

Serverpod handles database transactions through the `session.db.transaction` method. The transaction takes a method that performs any database queries or other operations and optionally returns a value.
Serverpod handles database transactions through the `session.db.transaction` method. The method takes a callback function that receives a transaction object. The transaction object is then passed to any database operation to be included in the same transaction.

The transaction is committed when the callback function returns, and rolled back if an exception is thrown. Any return value of the callback function is returned by the `transaction` method.

Simply pass the transaction object to each database operation method to include them in the same atomic operation:

Expand Down

0 comments on commit 1f4d501

Please sign in to comment.