tonsky / datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
Eclipse Public License 1.0
5.45k stars 304 forks source link

:db/cas should take a function #431

Closed jleonard-r7 closed 2 years ago

jleonard-r7 commented 2 years ago

a la clojure.core/swap!

It would be trivial to implement and would be vastly more user friendly.

tonsky commented 2 years ago

Does :db.fn/call solves it for you?

jleonard-r7 commented 2 years ago

Ah yes that works. I still think cas is not entirely useful in its current form because one typically wouldn't know the "old-value" without doing a query first.

tonsky commented 2 years ago

It might be useful for transactional semantics, I guess. You hold onto value, and when you decide to update it, make sure that nobody has updated it before you