I am writing a Reddit like comment store using Couchbase. For each comment, I am storing its
parentId and a list of its
childrenIds . Each top-level comment on a web page will have its
I want to retrieve a comment block efficiently. By a comment block, I mean a top-level comment along with all its children comments. So the first step in this can be to write a
map function that emits the
ids of all top-level comments.
How do I go about fetching the entire tree once I have the root. A very naive approach would be to find the children, and query them recursively. But this defeats the purpose of not using a relational database for this project (since I am dealing with highly nested data and relational databases are terrible at storing them).
Can someone guide me on this?