datascript

seepel 2022-07-24T00:42:41.550089Z

Can I specify a unique reverse relation like this?

[{:dom/client-id #:db{:cardinality :db.cardinality/one,
                     :valueType :db.type/ref,
                     :unique :db.unique/identity}
 {:dom/_attr+key #:db{:cardinality :db.cardinality/one,
                     :valueType :db.type/tuple,
                     :tupleAttrs [:dom/_attr :dom/attr-key],
                     :unique :db.unique/identity}}
if I am providing data like this?
{:dom/client-id "9fadb8a6-dfdc-40a7-84b0-9f2eef552345"
 :dom/attr #:dom-attr{:key "client-id",
                       :value "9fadb8a6-dfdc-40a7-84b0-9f2eef552345"}}

Niki 2022-07-25T11:12:47.508709Z

No, you can’t use leading underscore in schema at all

seepel 2022-07-25T20:12:41.915379Z

Thanks for the confirmation! I did end up creating a :dom/attr-parent to handle this and it seems to be working. I'm glad to understand why my previous schema wasn't working 🙂

seepel 2022-07-24T00:48:08.453899Z

My first example may not have been the best as client-id appears in two spots. Here is an example of storing an h1 tag in the db

[{:dom/type "heading",
  :client/id "9cc3dd5f-0242-4ff6-9869-5e6dc28e5831",
  :dom/attr #:dom-attr{:key "level", :value 1}}]