How to find User Hierarchy?


#1

hi everyone, i have user object like this:

User
{
        .........
        parentId: String,
        children: [String] // [userId1, userId2, userId3, ........]
       ...........
}

how to query for this result:

A {username: a, .... }
--B { username: b, age: 22,...}
----C {username: b}

Option 2 ( hander ): include parent and current user intro result, and highline current with { current: true }

Parent { username: z }
--A {username: a, ...., current: true }
----B { username: b, age: 22,...}
------C {username: b}

Enduser result i want:

<ul>
 <li>a
       <ul>
             <li>b | age: 22
                   <ul>
                         <li>c</li>
                   </ul>
             </li>
       </ul>
 </li>
</ul>

tree 2:

z (parent)
<ul>
 <li ><span style="color: red">a | current user</span>
       <ul>
             <li>b | age: 22
                   <ul>
                         <li>c</li>
                   </ul>
             </li>
       </ul>
 </li>
</ul>

#2

This meteorpedia article may help.