How to get tree of documents in couchbase. Bottom up approach?

parent:{

}
child:{
parentid:parent;
}
grantchild:{
parentid:child;
}

Use JOIN ANSI JOIN Support in N1QL | The Couchbase Blog if you know tree depth (There are no recursive operations) . If that doesn’t work USE SDKs construct tree using KV operations.

Thanks for response ,
is there any way to doing using map-reduce views.?

check this out blog.couchbase.com/n1ql-query-with-self-referencing-hierarchy