(:Dot)-[:CONTAINS]->(:Dot)
Not every dot has a container and also there are no loops. Atm a dot can only be contained by one other dot. So we are basically talking about trees
Now I would like to use Neo4j to retrieve the data and return it hierarchally (by containers):
[
{"id": 1, "containees": [
{"id": 3},
{"id": 4, "containees": [
{"id": 6},
]},
]},
{"id": 2, "containees": [
{"id": 5}
]}
]
The query shouldn't use a fixed depth.
Atm I only have this, and I'm really not sure what my options are concerning iterating a path.
MATCH (d:Dot)
OPTIONAL MATCH p = d-[:CONTAINS*]->(d2:Dot)
RETURN d.id