Reputation: 121
Say I have a graph that has vertices of labels 'Company' 'CarModel' and 'Parts' where a company has many car models and Car models have many parts. How can I query the Database to return to me all the properties of the Company with 'CarModels' as property that would be an array of the CarModel vertices then again return all the properties of CarModel with Parts as an additional property that has all the properties of Parts?
Upvotes: 0
Views: 179
Reputation: 2856
You can use project
step if you want to structure your answer and collect the required data from the graph for each key:
g.V().hasLabel('Company').
has('name', <Company Name>).
project('CompanyData', 'CarModels').
by(valueMap()).
by(out().
project('CarModelData', 'Parts').
by(valueMap()).
by(out().valueMap().fold()).fold())
example: https://gremlify.com/md1j1rzgigt
Upvotes: 1