Having trouble coming up with a good single query to get the results I'm looking for.
In this scenario I have reports, stores, and organizations.
Reports can only ever belong to one store, or one org. Never both. Stores always belong to an org, and can only ever belong to one org. Orgs can only ever be a sub-org of one org, but can be in a chain of multiple sub-orgs.
I'm looking for a single query that will take a report Id and give me the single top level org, regardless of how many levels of sub orgs there are.
Scenarios:
- report > store > org
- report > store > org > org > org
- report > org
- report > org > org > org
Current edge names are simply the in and out label names reportStore
& storeReport
, reportOrg
& orgReport
, storeOrg
& orgStore
, suborgOrg
& orgSuborg
The furthest I've gotten so far is g.V('<id>').until(has('label','org')).repeat(out()).limit(1)
but clearly this is not a direct shot, and it will stop as soon as it gets to the first org.