make tree data structure from query in Arangodb

429 Views Asked by At

I have 2 collections:

  • root - vertices
  • root_edges - edges

Each root_edge connects 2 root documents. I want to be able to make a query so that it will return nested data structure representing the data tree.

I want something like this:

A: {
    id: <int>,
    name: <string>
    B: {
        id: <int>,
        name: <string>,
        C: {
            id: <int>,
            name: <string>
        },
        D: {
            id: <int>,
            name: <string>
        }
    }
    E: {
        id: <int>,
        name: <string>,
        F: {
            id: <int>,
            name: <string>
        }
    }
}

I don't know how many levels can be there, so I need a flexible solution. What I have now produces a flat list of all edges and/or vertices.

0

There are 0 best solutions below