Fork me on GitHub

I’m sure I’m missing something, but does anyone know what might be causing this? (It’s fine locally, but it fails on a EC2 instance)


Someone already asked this, so sharing it here since it might be helpful to others:


I added this EC2 to the same VPC as Datomic Cloud - I’m not sure this is the way to go, I’m trying to figure things out.


I added an SSH inbound rule, but that’s it, I didn’t mess with any other configuration.


(Clojure CLI version


I create entities like so and put some values in those entities. So far there are no errors:

(d/transact conn [{:db/ident :carecoach/name
   :db/valueType :db.type/string
   :db/cardinality :db.cardinality/one
   :db/unique :db.unique/identity
   :db/doc "name"}
  {:db/ident :carecoach/number
   :db/valueType :db.type/long
   :db/cardinality :db.cardinality/many
   :db/unique :db.unique/identity
   :db/doc "number"}

(d/transact conn [{:carecoach/name "Prikshet" :carecoach/number 20}])

(d/transact conn [{:carecoach/name "Deepak" :carecoach/number 10}])

(d/transact conn [{:carecoach/name "Prikshet" :carecoach/number 30}])

(d/transact conn [{:carecoach/name "Deepak" :carecoach/number 20}])

(d/transact conn [{:carecoach/name "Prikshet" :carecoach/number 40}])

(d/transact conn [{:carecoach/name "Deepak" :carecoach/number 50}])
But when I try to do a pull, I get the following error:
(defn get-sum [name-string]
  (d/pull db '[*] [:carecoach/name name-string])
  #_(d/q '[:find ?number
         :in $ ?name-string
         [?e :carecoach/name ?name-string]
         [?e :carecoach/number ?number]
       db name-string)

(get-sum "Deepak")
:db.error/not-an-entity Unable to resolve entity: :carecoach/name
   {:entity :carecoach/name, :db/error :db.error/not-an-entity}
                 error.clj:   57  datomic.error/arg
                 error.clj:   52  datomic.error/arg
                    db.clj:  589  datomic.db/require-id
                    db.clj:   -1  datomic.db/require-id
                    db.clj:  689  datomic.db/require-attrid
                    db.clj:  686  datomic.db/require-attrid
                    db.clj:  534  datomic.db/resolve-lookup-ref
                    db.clj:  526  datomic.db/resolve-lookup-ref
                    db.clj:  568  datomic.db/extended-resolve-id
                    db.clj:  564  datomic.db/extended-resolve-id
                    db.clj:  579  datomic.db/resolve-id
                    db.clj:  572  datomic.db/resolve-id
How to fix this?


db is from before your transactions


again: you should use the return value of transact, and you should pass db in to querying functions as an argument


db is not a “database handle” like in a normal relational db. You can’t def it once. It’s an immutable value.


transactions change that value and return a new db


you can even use d/with to produce a new db value without committing it to storage.


what’s the fastest way to fix this? I’m in a hurry


As favila said, just change get-sum to take db as an argument. Pass in the the db-after you get from eg. derefing the return value of the last d/transact