Fork me on GitHub
#datomic
<
2021-07-02
>
pedrorgirardi04:07:26

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)

pedrorgirardi01:07:03

Someone already asked this, so sharing it here since it might be helpful to others: https://ask.datomic.com/index.php/546/could-not-find-artifact-com-datomic-ion-jar-0-9-48-in-central

pedrorgirardi04:07:19

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.

pedrorgirardi04:07:05

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

pedrorgirardi04:07:18

(Clojure CLI version 1.10.3.855)

zendevil.eth15:07:58

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
         :where
         [?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?

favila15:07:42

db is from before your transactions

favila15:07:13

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

favila15:07:33

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

favila15:07:52

transactions change that value and return a new db

favila16:07:42

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

zendevil.eth16:07:49

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

pyry17:07:46

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