Welcome! Please see the About page for a little more info on how this works.

0 votes
in On-Prem by

By way of example I'm going to use a drawing as the existing entity which is to have two new shapes added to it. This is the tx that is failing:
[{:shape/id "BKF806TXXTAFWII0", :db/id "22NF08ZVGH9N7QGG_0"} {:shape/id "YKIZU4CJC0JXJKVQ", :db/id "22NF08ZVGH9N7QGG_1"} [:db/add 17592186047451 :drawing/shapes ["22NF08ZVGH9N7QGG_0" "22NF08ZVGH9N7QGG_1"]]]

As you can see the existing drawing has :db/id of 17592186047451. I'm trying to create two new shapes and add them to the many cardinality attribute :drawing/shapes. "22NF08ZVGH9N7QGG_0" and "22NF08ZVGH9N7QGG_1" are tempids that are supposed to be translated to the same new :db/ids wherever they appear.

I should say that the drawing doesn't have any existing shapes. If it did I would expect them to be orphaned.

This is the error message I'm getting:

Execution error (ExceptionInfo) at datomic.client.api.async/ares (async.clj:58).
Cannot interpret as a keyword: 22NF08ZVGH9N7QGG_0, no leading :

Something similar I've also tried:
[{:shape/id "9HTL5BMMHT6QUJM6", :db/id "22NF08ZVGH9N7QGG_0"} {:shape/id "O5UB9IG9UB8KDVA2", :db/id "22NF08ZVGH9N7QGG_1"} [:db/add 17592186047451 :drawing/shapes "22NF08ZVGH9N7QGG_0"] [:db/add 17592186047451 :drawing/shapes "22NF08ZVGH9N7QGG_1"]]

Gives this error message:
Execution error (ExceptionInfo) at datomic.client.api.async/ares (async.clj:58).
Two datoms in the same transaction conflict
[17592186047451 :drawing/shapes 17592186049126 13194139538021 true],
[17592186047451 :drawing/shapes 17592186049127 13194139538021 true]}

This gives the same error message as the first attempt:
[{:db/id 17592186047451, :drawing/shapes ["22NF08ZVGH9N7QGG_0" "22NF08ZVGH9N7QGG_1"]} {:shape/id "3DZYWHEPQIAELF25", :db/id "22NF08ZVGH9N7QGG_0"} {:shape/id "GJ804SOOU36YQX6Y", :db/id "22NF08ZVGH9N7QGG_1"}]

Getting rid of the tempids by doing it in a nested way:
[{:db/id 17592186047451, :drawing/shapes [{:shape/id "GEMRMRFG0E6N262M"} {:shape/id "HTH2C7R90BQFFNXT"}]}]

Just yields this error message:
Execution error (ExceptionInfo) at datomic.client.api.async/ares (async.clj:58).
Unable to resolve entity: {:shape/id "GEMRMRFG0E6N262M"}

1 Answer

0 votes
edited by

This was answered here: https://stackoverflow.com/questions/73142317/in-datomic-how-to-add-new-entities-as-references-to-the-many-attribute-of-an
Basically the 2nd and 3rd attempts are correct. I was trying to perform a cardinality Many operation on a cardinality One attribute.