I have this schema:
{:db/ident :sentence/id
:db/valueType :db.type/string
:db/unique :db.unique/identity
:db/cardinality :db.cardinality/one}
{:db/ident :sentence/words
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many
:db/isComponent true}
{:db/ident :word/value
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one}
When I transact
(d/transact db [{::sentence/id "one" ::sentence/words [{::word/value "word"}]}])
=> {:db-before {...} :db-after {...} :tx-data [...] :tempids {...}}
However, when I transact
(d/transact db [{::sentence/id "one"}])
=> {:db-before {...} :db-after {...} :tx-data [...] :tempids {...}}
(d/transact db [[:db/add 1234567890 ::sentence/words {::word/value "word"}]])
=> Exception {:cognitect.anomalies/category :cognitect.anomalies/incorrect,
:cognitect.anomalies/message "Unable to resolve entity: {::word/value \"word\"}"}
Before trying it, I had assumed that nested maps would work both as part of a nested map and in :db/add
. Here is the documentation on nested map transactions.
Hopefully this note will help someone else in the future.