Is it possible to atomically make a query and use its result to make a transaction, so that there would be no other transactions (made by other concurrent processes) in-between the query and the transaction?
Hi @zhuxun2. Thanks for the questions! I am not aware of this functionality. Probably @konrad.kuehne or @whilo can answer regarding an implementation suggestion.
@zhuxun2 You need to use transactor functions for that. We have inherited the convention from DataScript: [:db.fn/call f args]
where f
is a function reference and will take db as first argument. You can then run a query in there on the database if you need to.
This is very flexible, but blocks other transactions for the duration of the call to this function (which is necessary for atomicity).
Also, why is d/transact
sync and d/transact!
async? The opposite is what I would expect.
transact
calls transact!
under the hood and therefore it is this way round. The transact!
-function will not be part of the public api in the future, but it will still be available for usage. There will be an async api comparable to the datomic.client.api and we hope to finish this soon.