I am trying to implement a organizational structure where one user can have more than one children users and parent users. Using cosmosDB as document database, I have stored the path of parent users in each user document.
Data Structure of user document
user1
path = null
user2
path = ["user1ID"]
user3
path = ["user2ID", "user1ID"]
user4
path = [["user1ID"], ["user3ID", "user2ID", "user1ID"]]
where path is List<List<string>>()
Problem: I wrote logic to update the paths of the users and find the flat list of ascendants and descendants of a user. The problem I am facing is to represent these list of users in hierarchy.
Output expected:
user1 ->
user2->
user3->
user4
user4
user2 ->
user3 ->
user4
user3 ->
user4
user4 ->
In front-end, i am using JsTree library to show the user hierarchies.
I looked for many solutions regarding this but couldn't find the way i am looking for. Any help would be appreciated.