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 like findChildren that would return (given a node/parent) children and its grandchildren in a nested array.
For example:
{
name: 'parent',
children: [
{
name: 'child1',
},
{
name: 'child2',
children: [
{
name: 'grandchild1',
children: [*so on*],
}
}
]
}
I have a model named
Pagewhich can have multiple children, which in return can have its own children (and so on).I would like to have a functiion like
findChildrenthat would return (given a node/parent) children and its grandchildren in a nested array.For example: