ArangoDB is great for retrieving a graph of data. A tree is a kind of graph.
We want to store data of buildings in a database. The structure of a building can be thought of as a hierarchy of parts.
The data structure is very simple: assemblies containing other assemblies, unlimited levels deep.
Assemblies are stored as documents, and linked by an edge collection contains
.
The data that I need, can be fetched with
FOR v, e, path IN 1..3 OUTBOUND
'assemblies/14810426' contains
RETURN path
The data is there, however, I want to have a json like
{name: "Office Building",
assemblies: [{name: "Director's office",
assemblies: [{name: "Chair"}, {name: "Desk"}]},
{name: "Toilet}]}
Is there a way to get this format straight from ArangoDB, or do I need to write code myself to convert the graph path to a tree?
I guess writing a Foxx service is an option, but I would like to avoid that.
There is a similar question, with answer, but that was for the previous version of ArangoDB. It requires a bit of foxx code. I was hoping to have a solution, straight from AQL.