Here, I've a sample document of my DB Collection,
{
user:"758bd45b-0741-430b-ae3c-af0f1c2e42b7"
referral:"467da3eb-3229-4bb2-82c0-3b2f440d378c"
refUserId:"84e8c706-8d26-43e9-9d9a-1df114a3e97d"
status:"SUCCESS"
}
Here, User id UserId, refUserIs means the referee Who invited this user. What I expecting is I need to get the tree/ Hirearch view with these details.
Example Scenario:
If I enter a UserID then It has to show me the details in tree view like the below expecting result
{
“id”: 2,
“full_name”: “Henry”,
“parent”: {
“id”: 1,
“full_name”: “William”
},
“children”: [
{
“id”: 3,
“full_name”: “Matt”,
“parent”: {
“id”: 2,
“full_name”: “Henry”,
“parent”: {
“id”: 1,
“full_name”: “William”
}
}
},
{
“id”: 4,
“full_name”: “Alisa”,
“parent”: {
“id”: 2,
“full_name”: “Henry”,
“parent”: {
“id”: 1,
“full_name”: “William”
}
}
}
]
}
It’s for just one user, similarly have to get them all collection under one endpoint with the hierarchy view and get the depth of each userflow.
I will be grateful if you can suggest me the correct MongoDB Queries and SpringBoot Example(If Possible)