datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
Joe Lane 2021-07-02T01:09:16.380900Z

There is no distinct “memory space” so your ion should be able to access any state that is correctly instantiated. Http-direct and lambda proxy’s both call ions. As long as the state is present on all cluster nodes you should be able to access it. however mount can add it’s own challenges due to piggy backing on ns loading. I can usually get by without a framework and instead just wrap my state in a delay and initializing it on the first access (what delays are for).

pedrorgirardi 2021-07-02T04:20:26.382700Z

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)

pedrorgirardi 2021-07-05T01:13:03.392200Z

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

pedrorgirardi 2021-07-05T02:14:02.392800Z

https://clojure.org/reference/deps_and_cli#_maven_s3_repos

pedrorgirardi 2021-07-02T04:20:32.382800Z

pedrorgirardi 2021-07-02T04:22:19.384200Z

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.

pedrorgirardi 2021-07-02T04:23:05.385Z

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

pedrorgirardi 2021-07-02T04:25:18.385300Z

(Clojure CLI version 1.10.3.855)

zendevil 2021-07-02T15:55:58.387100Z

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?

favila 2021-07-02T15:58:42.387200Z

db is from before your transactions

favila 2021-07-02T15:59:13.387400Z

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

favila 2021-07-02T15:59:33.387600Z

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

favila 2021-07-02T15:59:52.387800Z

transactions change that value and return a new db

favila 2021-07-02T16:00:42.388Z

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

zendevil 2021-07-02T16:26:49.388400Z

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

pyry 2021-07-02T17:18:46.388600Z

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