我正在使用 angular-ui-tree 库来显示文件夹结构。
我将节点对象存储在 MongoDB 数据库中。
每个节点对象看起来像这样
{
"node_name" : "Folder 1",
"node_path" : "AAABBB",
"node_id" : 103,
"node_parent_path" : "AAA",
"node_parent_id" : 13,
"template" : "Template 1"
}
Angular-UI-TREE 以这种方式填充
data = [ {
"node_name" : "Folder 1",
"node_path" : "AAABBB",
"node_id" : 103,
"node_parent_path" : "AAA",
"node_parent_id" : 13,
"nodes" : [
{
"node_name" : "Folder 1-1",
"node_path" : "AAABBBAAA",
"node_id" : 10351,
"node_parent_path" : "AAABBB",
"node_parent_id" : 103,
"nodes" : [
{
"node_name" : "Folder 1-1-1",
"node_path" : "AAABBBAAAAAA",
"node_id" : 415,
"node_parent_path" : "AAABBBAAA",
"node_parent_id" : 10351,
"nodes" : []
}
]
},
{
"node_name" : "Folder 1-2",
"node_path" : "AAABBBBBB",
"node_id" : 103531,
"node_parent_path" : "AAABBB",
"node_parent_id" : 103,
"nodes" : [
]
},
]
},
{
"node_name" : "Folder 2",
"node_path" : "AAACCC",
"node_id" : 104,
"node_parent_path" : "AAA",
"node_parent_id" : 13,
"nodes" : []
}
]
有了这些数据,树看起来像
Folder 1
|
---> Folder 1-1
|
---> Folder 1-1-1
|
---> Folder 1-2
Folder 2
从使用如上所示模式存储在 mongoDB 中的一堆节点中,我想填充 DATA 数组以便能够填充 UI 树..
最好的方法是什么?
或者有没有更好的方法将这些节点存储在数据库中,以便更轻松地检索该信息以填充树?