Fork me on GitHub
#datomic
<
2020-05-13
>
vnctaing19:05:32

I have issue trying to do a simple query with on-prem, my get-all fn throws this anomalie. Query args must include a database

(ns oceans-eleven.db.core
  (:require
   [datomic.client.api :as d]
   [io.rkn.conformity :as c]
   [mount.core :refer [defstate]]
   [clojure.pprint :as p]
   [ring.util.request]
   [oceans-eleven.config :refer [env]]))

(def cfg {:server-type        :peer-server
          :access-key         "myaccesskey"
          :secret             "mysecret"
          :endpoint           "localhost:8998"
          :validate-hostnames false})

(def client (d/client cfg))

(def conn (d/connect client {:db-name "pensine"}))

(def o11-schema [{:db/ident       :trip/name
                  :db/valueType   :db.type/string
                  :db/cardinality :db.cardinality/one}])

(def all-trips '[:find ?e
                 :where [_ :trip/name ?e]])
(defn get-all [e]
  (d/q {:query all-trips :args [ conn ]}))

;; I also tried  this 
;; (defn get-all [e]
;;   (d/q all-trips conn))

vnctaing19:05:43

I’m using [com.datomic/datomic-pro "0.9.5981"] [com.datomic/client-pro "0.9.41"]

ghadi19:05:53

@vnctaing you're passing the connection to the query, not the db

ghadi19:05:03

you can get a database from a connection

🤯 4
ghadi19:05:05

(d/db conn)

4
ghadi19:05:15

that gives you a db-as-a-value

ghadi19:05:19

always pass a database explicitly as an argument to functions that call d/q

👍 4
ghadi19:05:32

never discover a database from the "inside out"

ghadi19:05:21

(defn ask-the-database-something 
  [db ...]
  (d/q  {:query .... :args [db ...]}))