Open ashoktamang opened 9 months ago
findDescendants
is the function that will give you the result you are looking for but in a flat array.
That said I like the idea of creating a nested array from a flat array. I imagine it as a utility function that take the result of any function call and format it into a nested array tree.
I have a model named
Page
which can have multiple children, which in return can have its own children (and so on). I would like to have a functiion likefindChildren
that would return (given a node/parent) children and its grandchildren in a nested array.For example: