-
Type: New Feature
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
Add transaction method to Mongoid module. This method accepts a block, and all operation inside the block are wrapped in a mongodb transaction.
Successful Transaction
Mongoid.transaction do # ... end
will result in:
- Default client starts a new session.
- A transaction is started on the created session.
- All the server commands issued by the code inside the block are sent with the session option.
- When the block is completed, the transaction is committed.
Failed Transaction
Failed transaction means that the code inside the transaction block raises an exception.
Mongoid.transaction do # ... raise SomeError # ... end
will result in:
- Default client starts a new session (see more about used clients below).
NOTE
Callbacks are not in the scope of this ticket.
- A transaction is started on the created session.
- All the server commands issued by the code inside the block before the exception are sent with the session option.
- When the exception is raised, the transaction is aborted.
- clones
-
MONGOID-5530 Add transaction method
- Closed
- has to be done before
-
MONGOID-5531 Add after_commit and after_rollback callbacks
- Closed