Certainly a dumb question, but hopefully should clear things up.
I am following along https://docs.datomic.com/on-prem/getting-started/transact-schema.html, and the step to transact the schema, in this tutorial, is
user=> (d/transact conn {:tx-data movie-schema})
However, when I try this, I get
ClassCastException clojure.lang.PersistentArrayMap cannot be cast to java.util.List datomic.api/transact
Instead, when I just do
(d/transact conn schema)
it works for me. Is the tutorial missing some subtlety here? Am I missing something? (the only difference is that I'm using the Free version instead of the Starter Pro version).
Edit: the initial version of this post mentioned the schema, but this is generally true for just adding new facts too (i.e. using {:tx-data foo}
doesn't work, but just using foo
does).
I think the cause of your problem here is an inconsistency between the Peer API (in which transact
accepts a list) and the Client API (in which transact
accepts a map containing a :tx-data
key). I suspect you tried to run your REPL commands in the REPL of a Peer process, whereas the tutorial you linked to expects you to run commands in the REPL of a Client process.
Why the inconsistency between Peers and Clients? Not being part of the Datomic team, I can only speculate:
d/transact
(I believe it incurs an additional I/O roundtrip from client to server), the authors left room for additional data in transaction requests (e.g for templating), hence the more extensible map-based format.