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 に格納された一連のノードから、UI ツリーを作成できるように DATA 配列を作成したいと考えています。
これを行う最良の方法は何ですか?
または、これらのノードをデータベースに格納して、その情報を取得してツリーに入力しやすくするためのより良い方法はありますか?