datascript

Immutable database and Datalog query engine for Clojure, ClojureScript and JS
lilactown 2020-03-13T15:33:41.026700Z

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

lilactown 2020-03-13T15:34:33.027700Z

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

lilactown 2020-03-13T15:35:09.028500Z

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

lilactown 2020-03-13T15:35:40.029100Z

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

lilactown 2020-03-13T15:37:43.030Z

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

lilactown 2020-03-13T15:43:14.030600Z

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

danieroux 2020-03-17T07:32:58.030900Z

:thumbsup: So much fun working with this Datascript thing