I am trying to insert a new object into my Datomic database with references to the enum / ref types that I created ( :client/gender
and :client/referral
).
Writing a schema to a type :client/referral
looks like this (and the definition is :client/gender
almost identical):
{:db/id
:db/ident :client/referral
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/one
:db/doc "The referral source for this client"
:db.install/_attribute :db.part/db
}
[:db/add
[:db/add
[:db/add
The transaction function looks something like this (I tried all the options):
(defn add-client [client]
(let [gender (:gender client)
referral (:referral client)]
@(d/transact conn
[{:db/id (d/tempid :db.part/user)
:client/name (:name client)
:client/phone (:phone client)
:client/email (:email client)
:client/date-of-birth (:dateOfBirth client)
:client/gender gender
:client/referral referral}])))
In this particular embodiment, the following error occurs:
java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: :db.error/not-an-entity Unable to resolve entity: 17592186045422 in datom [
...
Caused by: datomic.impl.Exceptions$IllegalArgumentExceptionInfo: :db.error/not-an-entity Unable to resolve entity: 17592186045422 in datom [
error.clj:57 datomic.error/arg
error.clj:55 datomic.error/arg
db.clj:555 datomic.db/require-id
db.clj:2334 datomic.db/datomic.db.ProcessInpoint
db.clj:2317 datomic.db/datomic.db.ProcessInpoint
db.clj:2512 datomic.db/with-tx[fn]
PersistentVector.java:333 clojure.lang.PersistentVector.reduce
core.clj:6518 clojure.core/reduce
db.clj:2512 datomic.db/with-tx[fn]
db.clj:2516 datomic.db/with-tx
peer.clj:558 datomic.peer.LocalConnection/fn
peer.clj:558 datomic.peer/datomic.peer.LocalConnection
peer.clj:550 datomic.peer/datomic.peer.LocalConnection
api.clj:94 datomic.api/transact
...
I also tried such options (among other things), but to no avail:
@(d/transact conn
[{:db/id (d/tempid :db.part/user)
:client/name (:name client)
:client/phone (:phone client)
:client/email (:email client)
:client/date-of-birth (:dateOfBirth client)
:client/gender
:client/referral
What, possibly, am I missing?
source
share