3 ms·
Now I’m curious: what’s a useful example of a Datomic transaction that reads a value in multiple of its elements and modifies it?
by amluto 2y ago
Now I’m curious: what’s a useful example of a Datomic transaction that reads a value in multiple of its elements and modifies it?
- lgrapenthin 2y agoYou could include two transaction functions that constrain a transaction to different properties about the same fact and then alter that fact. I don't know of a practical usecase or that I ever encountered that, it would be extremely rare IME.
- hlship 2y agoIn traditional databases, only the database engine has a scalable view of the data - that’s why you send SQL to it and stream back the response data set. With Datomic, the peer has the same level of read access as the transactor; it’s like the database comes to you. In this read and update scenario, the peer will, at its leisure, read existing data and put together update data; some careful use of compare and set, or a custom transaction function, can ensure that the database has not changed between read and writes in such a way that the update is improper, when that is even a possibility - a rarity. At scale, you want to minimize the amount of work the transactor must perform, since it so aggressively single threaded. Off loading work to the peer is amazingly effective.