den1k / subgraph

Reactive graph database for re-frame
Other
78 stars 2 forks source link

Consider using tree structure for entities #16

Open p-himik opened 6 years ago

p-himik commented 6 years ago

Right now SubGraph stores entities directly in app-db under keys that look like [:some-keyword some-key-value]. It makes it incredibly hard to look at app-db with the naked eye or with tools like https://github.com/flexsurfer/re-frisk. I think it would make sense to use a tree structure and store the entities like {:some-keyword {some-key-value some-value}}. So instead of e.g. this

{[:a/id 1] {:id 1 :name "x"}
 [:a/id 2] {:id 2 :name "y"}}

it would be this

{:a/id {1 {:id 1 :name "x"}
        2 {:id 2 :name "y"}}}
p-himik commented 6 years ago

Another advantage of this approach is that it allows for fast querying of all entities of the same type (well, having the same ID attrs). That being said, I think it would also make sense to make it possible to rename the top-level key. It would also make it more simple to incorporate SubGraph into the existing app-dbs.