This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-29
Channels
- # announcements (1)
- # babashka (15)
- # beginners (37)
- # calva (94)
- # cider (3)
- # clj-kondo (17)
- # cljsrn (2)
- # clojure (45)
- # clojure-europe (39)
- # clojure-germany (1)
- # clojure-norway (2)
- # clojurescript (16)
- # component (18)
- # conjure (1)
- # cursive (13)
- # datalevin (3)
- # datomic (12)
- # docker (2)
- # duct (5)
- # eastwood (2)
- # emacs (4)
- # events (8)
- # fulcro (8)
- # inf-clojure (5)
- # kaocha (8)
- # lsp (24)
- # malli (11)
- # meander (3)
- # off-topic (19)
- # polylith (11)
- # remote-jobs (4)
- # sci (61)
- # shadow-cljs (9)
- # spacemacs (34)
- # sql (10)
- # tools-deps (27)
- # xtdb (10)
is there any way to say “add n to a value” multiple times in a transaction, without having to coordinate the real values?
No, you have to prepare your tx data differently. Transactions are run and applied atomically: there’s no db to read which ever had only some of your updates but not others
i’ll turn it around, and have multiple data supplied to the tx fn, and do the calculation there
ie, if I say that [[:db/add "foo" :some/metric 1] [:db/add "foo" :some/metric 2]...]
- i clearly get conflicts. what’s the solution?
if i use a tx fn, it’s the same problem, as it expands to the same tx data - unless I’m missing something?
no, you have to do this addition when preparing the tx-data. but consider the possibility to do several transactions as well, they can sometimes be batched.
when I’ve wanted to do something similar I ended up doing a little processing on the accumulated tx-data before actually transacting, to coalesce accretive changes like this.
@U060QM7AA in the transactor, or the peer? I’m thinking a tx function that can take multiple items would be the simplest - but this condition that each transaction can only have one of these calls annoys.