I'm really trying hard to understand this new concept after working so long with relational databases...
Can anyone explain how I should go about storing say, a category hierarchy?
in a relational DB, I'd have:
Category:
CategoryId
ParentCategoryId
Name
or something of that nature..
You can start with the same approach as you would with relational databases: creating a separate document for each category, and keeping a reference to the parent category.
If you'd like to query a whole subtree or breadcrumbs with a single query, you should maintain an array field that contains all the ancestor keys. Then you can create a view that walks through the ancestors and emits [ancestor_key, doc]
for querying a subtree. To get the breadcrumbs data for a category make a bulk query on the ancestor IDs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With