Search code examples
clojuredatomic

Error returning a Map instead of a Vector using Datomic


I'm doing some query in Datomic using Clojure, I'm trying to return a Map with keys instead of a Vector, if I don't try to return a Map with the ":keys" keyword in the query it works fine.

I tried to have equal and different names between the :find and :keys. If I remove the :keys line bellow it works fine.

I'm using [org.clojure/clojure "1.10.0"] with [com.datomic/client-pro "0.8.28"].

(def get-links
        '[:find ?e ?url ?description ?createdat ?order ?postedby
          :keys e url description createdat order postedby
          :in $ ?filter ?skip ?skip-plus-first
          :where [?e :link/url  ?url]
                  [?e :link/description ?description]
                  [?e :link/createdat ?createdat]
                  [?e :link/postedby ?e2]
                  [?e :link/order ?order]
                  [?e2 :user/name ?postedby]
                  [(.contains ?url ?filter)]
                  [(> ?order ?skip) ]
                  [(<= ?order ?skip-plus-first)]])

Here is how I'm calling it:

(d/q get-links db filter skip (+ first skip))

The exact error is: Execution error (ExceptionInfo) at datomic.client.api.async/ares (async.clj:56).

"Argument :keys in :find is not a variable"

Below is Datomic examples, in their docs.

[:find ?artist-name ?release-name
 :keys artist release
 :where [?release :release/name ?release-name]
 [?release :release/artists ?artist]
 [?artist :artist/name ?artist-name]]

Solution

  • I think that you are using an older version of the client that doesn't know the :keys option yet.