Fork me on GitHub
#datomic
<
2020-09-05
>
Vishal Gautam18:09:21

I am working on an app where I am using d/with function to store intermediate transaction steps. I want to apply all the changes I made using d/with to actual database. How can that be achieved

val_waeselynck22:09:17

I don't see any trivial way to do that. You could keep track of your transaction results, compacting the added datoms into one transaction of the same effect. Such a compaction is not straightforward, as the intermediary transactions might produce conflicting datoms, and new entities might have been created in the way. In addition, in the general case, you're facing a potential concurrecy issue here, because computing changes speculatively and submitting them later is not transactional. Between the moment you compute your changes locally, and the moment you transact them, another transaction might have occured, causing your changes to violate an invariant (for example, setting a banking account's balance to a wrong amount, effectively erasing the result of a transfer).

👍 3
val_waeselynck22:09:12

My point here is that there's no way to make this foolproof without knowing more about the nature of your changes.

👍 3