c# - represent tree data structure with multiple parents whose parent path is stored in model
问题描述
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.
解决方案
推荐阅读
- scala - Akka committableOffset 存储在数据库中
- python - 用 astropy 和 fit_wcs_from_points 拟合天顶等面积投影
- arrays - bash - 使用带有 find 命令的数组
- tcsh - 在 tcsh 中获取文件时,RHEL6 和 RHEL7 之间的错误管理不同
- python - 有没有办法提取软件创建的图形的 .tiff 图像的私有标签中包含的数据?
- javascript - 不再工作的旧 JQuery 代码(wordpress)
- mongodb - MongoDriver for Scala + http4s:如何检查 createCollection() 是否抛出异常?
- asp.net-mvc - 路由参数约束“mongoId”未解决。为什么?
- git - 出现错误后如何在 iOS 上启动我的应用程序:PhaseScriptExecution [CP-User]
- docker - Docker-compose.yaml - 单行卷声明和绑定类型声明之间的区别