i love this table! https://docs.datomic.com/transactions/transaction-functions.html#when-to-use how did the name 'sagas' come to be? is there any description of this somewhere, for the curious?
the https://en.wikipedia.org/wiki/Long-running_transaction#cite_note-1 references https://web.archive.org/web/20220308200802/ftp://ftp.cs.princeton.edu/reports/1987/070.pdf
but that archive pdf doesnβt load for me, maybe https://www.cs.cornell.edu/andru/cs711/2002fa/reading/sagas.pdf is the same
thanks @mkvlr!
FYI @joe.lane, I have a repro for a π
details in thread! update: false alarmdatomic.api/invoke issue
(require '[datomic.api :as d])
(def uri "datomic:")
(d/create-database uri)
(def conn (d/connect uri))
;; copied from
(def add-user-code
'(if (every? umap [:name :email])
[{:user/name (:name umap)
:user/email (:email umap)}]
(datomic.api/cancel {:cognitect.anomalies/category :cognitect.anomalies/incorrect
:cognitect.anomalies/message "User map must contain :email and :name"})))
@(d/transact conn [{:db/ident :add-user
:db/fn (d/function {:lang "clojure" :params '[db umap] :code add-user-code})}])
;; end of copy
(d/invoke (d/db conn) :add-user {:name "Marshall" :email ""})
;; I expect:
[{:user/name "Marshall"
:user/email ""}]
;; I actually get:
;; 1. Unhandled clojure.lang.ArityException
;; Wrong number of args (1) passed to: ns-211284/eval211285/fn--211286
;; AFn.java: 429 clojure.lang.AFn/throwArity
;; AFn.java: 32 clojure.lang.AFn/invoke
;; function.clj: 36 datomic.function.Function/invoke
;; AFn.java: 154 clojure.lang.AFn/applyToHelper
;; function.clj: 46 datomic.function.Function/applyTo
;; core.clj: 667 clojure.core/apply
;; core.clj: 662 clojure.core/apply
;; db.clj: 2072 datomic.db/invoke
;; db.clj: 2070 datomic.db/invoke
;; RestFn.java: 145 clojure.lang.RestFn/applyTo
;; core.clj: 671 clojure.core/apply
;; core.clj: 662 clojure.core/apply
;; api.clj: 217 datomic.api/invoke
;; api.clj: 215 datomic.api/invoke
;; RestFn.java: 445 clojure.lang.RestFn/invoke
;; REPL: 54 my-test-ns/eval211282 false alarm. turns out i should be passing the db twice π once for d/invoke and again as the first arg to the tx fn:
(d/invoke (d/db conn) :add-user (d/db conn) {:name "Marshall" :email ""})
now it works!it's obvious in hindsight, but for those who need foresight (likely like myself 6 months from now), i humbly request that a copy/paste-capable example of d/invoke be added (complete with shout out about the double database param) to https://docs.datomic.com/transactions/transaction-functions.html please π