Fork me on GitHub
#datascript
<
2020-03-13
>
lilactown15:03:41

say I'm trying to transact a tree of comments. I have {:id 1, :content: "...", :comments [{:id 2, :content "..."}, ...]}

lilactown15:03:33

I've done the work of denormalizing this into a flat vector of comments. how do I ensure that the :comments reference is maintained?

lilactown15:03:09

I tried transacting like [{:id 1, :content "...", :comments [:id 2]}]

lilactown15:03:40

but that throws an error, "Nothing found for entity ID [:id 2]"

lilactown15:03:43

am I supposed to assign each comment a unique negative :db/id and use that as the ref lookup?

lilactown15:03:14

aha, I do not need to denormalize it at all 😂 transacting a nested map just works

danieroux07:03:58

:thumbsup: So much fun working with this Datascript thing