I have some employee data which is in the format
- Each employee has a manager
- Manager is also an employee
- Top level manager does not have a manager
So, my documents looks like
123
{
“type”:“employee”,
“name”:“john”,
“manager”:“456”
}
456
{
“type”:“employee”,
“name”:“ricky”,
“manager”:“789”
}
789{
“type”:“employee”,
“name”:“david”
}
Here employee 123 has a manager 456 who in turn has a manager 789. Now i would like to know how to retrieve the data in couchbase if “i want to get all hierarchy of employee 123”. So, if my input is 123 then i need to get all the above 3 documents. In regular rdbms, we can write hierarchical/recursive queries to get this kind of data with a single query. how do we do this couchbase. I am using latest java sdk.