I am using the angular-ui-tree library to display the folder structure.
I am storing the node objects in a MongoDB database.
Each node object looks like this
{
"node_name" : "Folder 1",
"node_path" : "AAABBB",
"node_id" : 103,
"node_parent_path" : "AAA",
"node_parent_id" : 13,
"template" : "Template 1"
}
The Angular-UI-TREE gets filled in this way
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" : []
}
]
With this data , the tree would look something like
Folder 1
|
---> Folder 1-1
|
---> Folder 1-1-1
|
---> Folder 1-2
Folder 2
From bunch of nodes stored in the mongoDB using the schema liked shown as above, I want to populate the DATA array to be able to populate a UI Tree..
What would be the best way to do this?
Or are there any better way to store these nodes in the database to make it easier to retrieve that information to populate the tree?