datomic

robert-stuttaford 2025-08-26T08:40:00.776869Z

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?

πŸ’― 6
1
❀️ 4
mkvlr 2025-08-26T08:59:59.583179Z

but that archive pdf doesn’t load for me, maybe https://www.cs.cornell.edu/andru/cs711/2002fa/reading/sagas.pdf is the same

robert-stuttaford 2025-08-26T10:52:52.826599Z

thanks @mkvlr!

robert-stuttaford 2025-08-26T13:56:25.459669Z

FYI @joe.lane, I have a repro for a datomic.api/invoke issue πŸ˜… details in thread! update: false alarm

robert-stuttaford 2025-08-26T13:56:35.738829Z

(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

robert-stuttaford 2025-08-26T14:16:37.028199Z

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!

robert-stuttaford 2025-08-26T14:19:45.496589Z

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 πŸ˜„