Open eko234 opened 3 years ago
There's a hint for transactions here: https://github.com/fukamachi/caveman/issues/69
(defmacro with-transaction (&body body)
`(cl-dbi:with-transaction *connection*
,@body))
@eko234 I have a transactions library for mito
here https://code.rhodecode.com/u/someseven/mito-transactions
I used it in two non-published (yet) projects and there are somewhat comprehensive tests.
@eko234 I have a transactions library for
mito
here https://code.rhodecode.com/u/someseven/mito-transactionsI used it in two non-published (yet) projects and there are somewhat comprehensive tests.
Cool, thank you so much.
@eko234 For your use-case just replace mito
package with mito-transactions
and wrap transaction code in (mito-transactions:with-transaction () ...)
. It redefines deftable
and simply reexports the rest of mito
so no other behaviour should change. cl-dbi:with-transaction
only handles the database. mito-transactions:with-transaction
makes sure in-image DAOs are also kept valid.
Does mito exposes a way to explicitly handle transactions? I have a use case in which I would like to update a object along with objects related to it, i.e. an album and it's songs, I'm not aware of a way to update nested objects with mito, I can do it in an iterative way though. The thing is I would like the transaction to rollback if an operation with an object related to the main object fails or if I explicitly raise a condition, is there a way to do it in mito?