Fork me on GitHub
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


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

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

👍 3