-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build tree hierarchy by ancestors #5
Comments
Can you please share an example? |
Yes, sure. For example you have flat list of nodes: This list should be converted to: { |
It seems that's not a tree, because a tree node should have just one ancestor (or parent) right? |
node3 should be the child node of node2 |
you could see an example how this tree structure stored in mongodb https://docs.mongodb.org/manual/tutorial/model-tree-structures-with-ancestors-array/ |
ok, got it, that's an optimization for fast path retrieval. For tree construction, all that's necessary is the last ancestor. I guess that could be supported if instead of using a Something like: flatToNested = new FlatToNested({
// The function to get the parent id
parent: function (node) {
return node.ancestors[node.ancestors.length - 1];
}
}}); What do you think? |
Looks good to me. |
It would be great to have possibility to build hierarchy tree not only by parent reference but with ancestors also.
The text was updated successfully, but these errors were encountered: