Is it possible to make an atomic transaction consists of a d/q
, some clojure computation, and a d/transact
call? How do I ensure that no other thread can change the state of the database before I finish the final d/transact
?
Would something like this work?
(locking conn
(let [res (d/q ...)]
...computation...
(d/transact conn ...))
@zhuxun2 Have a look at the compare-and-swap function. https://docs.datomic.com/cloud/transactions/transaction-functions.html#db-cas