Search code examples
azure-cosmosdbgremlintinkerpop3

Gremlin CosmosDB trying to query for a list of nodes from a list of nodes and give both back


graph image

enter code here
(Query to find owner)
.inE().hasLabel('OwnedBy').outV().not(inE().hasLabel('AssignedTo').has('Status', 'InUse'))
.not(
inE()
.hasLabel('AssignedTo')
.has('Status', 'InUse')
).as('cards')

.inE()
.hasLabel('AssignedTo')
.has('Status', 'FutureUse')
.as('OwnedByRequestEdges')

.outV()
.as('OwnedByRequests')

.Select('card', 'OwnedByRequests', 'OwnedByRequestEdges', 'Owner')

I really want it to give me a list of the cards and the list of the requests.

I user can have multiple cards and cards can have multiple future reservations.


Solution

  • In order to store all the values during traversal, you should use "store" and not "as".

    Since you want the "select" to run once, you need to add fold() before it.

    There was a redundant "not" filter (same filter).

    (Query to find owner)
    .inE().hasLabel('OwnedBy').outV()
    .not(inE().hasLabel('AssignedTo').has('Status','InUse'))
    .store('Cards')
    .inE().hasLabel('AssignedTo').has('Status', 'FutureUse').outV()
    .store('OwnedByRequests')
    .fold()
    .select('Cards', 'OwnedByRequests')