This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-15
Channels
- # babashka (12)
- # beginners (88)
- # calva (6)
- # cider (4)
- # clerk (110)
- # clojure (18)
- # clojure-czech (1)
- # clojure-europe (26)
- # clojure-nl (1)
- # clojure-norway (7)
- # clojure-poland (8)
- # clojure-spain (2)
- # clojure-uk (2)
- # clojurescript (22)
- # cursive (11)
- # data-science (1)
- # datalevin (5)
- # datomic (35)
- # events (1)
- # fulcro (2)
- # gratitude (5)
- # helix (4)
- # hoplon (20)
- # hyperfiddle (52)
- # jobs (3)
- # lsp (1)
- # malli (48)
- # missionary (11)
- # off-topic (31)
- # practicalli (1)
- # reitit (7)
- # releases (1)
- # remote-jobs (7)
- # scittle (9)
- # shadow-cljs (7)
- # sql (11)
- # xtdb (5)
I am attempting to understand transaction functions, but the example provided in the language reference seems to not work on my end. What am I doing wrong?
(defonce node (xt/start-node {}))
(xt/submit-tx node [[::xt/put
{:xt/id :increment-age
;; note that the function body is quoted.
;; and function calls are fully qualified
:xt/fn '(fn [ctx eid]
(let [db (xt/db ctx)
entity (xt/entity db eid)]
[[::xt/put (update entity :age inc)]]))}]])
(xt/submit-tx node [[::xt/put {:xt/id :ivan, :age 40}]])
(xt/submit-tx node [[::xt/fn :increment-age :ivan]])
(xt/entity (xt/db node) :ivan)
;; => {:age 40, :xt/id :ivan}
I am expecting the age to have been incremented to 41
, but it is still 40
. For reference, I am using [com.xtdb/xtdb-core "1.23.2"]