Fork me on GitHub
#xtdb
<
2022-09-25
>
macrobartfast05:09:17

this works fine:

(def treefrog-sample-data
  [{:treefrog/latin-name "Bix"
    :treefrog/common-name "Bax"
    :treefrog/nickname "Bob"
    :xt/id (java.util.UUID/randomUUID)}
   {:treefrog/latin-name "Biz"
    :treefrog/common-name "Baz"
    :treefrog/nickname "Joe"
    :xt/id (java.util.UUID/randomUUID)}])

(xt/submit-tx thenode
              (for [doc treefrog-sample-data]
                [:xtdb.api/put doc]))

but this: 
(xt/submit-tx thenode [:xtdb.api/put {:treefrog/latin-name “Bix” :treefrog/common-name “Bax” :treefrog/nickname “Bob” :xt/id (java.util.UUID/randomUUID)}])
produces:
1. Unhandled java.lang.IllegalArgumentException Don’t know how to create ISeq from: clojure.lang.Keyword RT.java: 557 clojure.lang.RT/seqFrom RT.java: 537 clojure.lang.RT/seq core.clj: 139 clojure.core/seq core.clj: 2750 clojure.core/map/fn
What am I missing?

UPDATE: this works (with the double square brackets)...

(xt/submit-tx thenode
              [[:xtdb.api/put
                             {:treefrog/latin-name "Bix"
                              :treefrog/common-name "Bax"
                              :treefrog/nickname "Bob"
                              :xt/id (java.util.UUID/randomUUID)}]])

but I could use a bit more understanding here.

refset06:09:43

Hey, you just need an extra set of [ ] 🙂

macrobartfast06:09:21

our messages just crossed… I had just updated my question as you posted your answer… thank you!

😄 1
🙏 1
Jacob O'Bryant19:09:54

> but I could use a bit more understanding here It's because each a transaction is a vector of operations, and each operation is itself a vector (`[:xtdb.api/put {...}]`). So if you call (xt/submit-tx node [:xtdb.api/put {...}]), xt thinks that :xtdb.api/put is an operation by itself. i.e. it expects to get a vector, but in fact gets a keyword, hence the Don't know how to create ISeq from: clojure.lang.Keyword message.

🙏 1
macrobartfast06:09:48

Ah, gotcha now. This is helpful. 👍🙂