Skip to content
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

Return children recursively in nested array. #67

Open
ashoktamang opened this issue Sep 9, 2023 · 2 comments
Open

Return children recursively in nested array. #67

ashoktamang opened this issue Sep 9, 2023 · 2 comments
Labels
feature New feature or request

Comments

@ashoktamang
Copy link

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*],
        }
      }
    ]
}

@adamjkb adamjkb added the feature New feature or request label Sep 9, 2023
@adamjkb
Copy link
Owner

adamjkb commented Sep 9, 2023

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.

@Tsimopak
Copy link

Hi @adamjkb , is there an ETA for this one? it's like a mandatory thing for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants