Reputation: 687
lets imagine I have this graph
and I want to query for all the partners connected to an user
WITH partner
FOR u IN user
FILTER u._name == @user_name
FOR v IN OUTBOUND user GRAPH 'accounts'
RETURN v
this query works when @user_name == Client
because it's only connected to partners but when @user_name == Admin
the profiles are returned also, when I expected an empty list (because user Admin
has no partners)
Am I using the keyword WITH
in the correct manner?
Upvotes: 1
Views: 49
Reputation: 11865
The purpose of the WITH
keyword is to specify the collections involved in a traversal, so that they can be read-locked at query start instead of lazily during traversal, which can lead to dead lock situations. It it required for traversals in a cluster.
It does not affect the query result. If you want to return paths that end at nodes from a certain collection only, use a filter with IS_SAME_COLLECTION():
WITH user, partner, profile
FOR u IN user
FILTER u._name == @user_name
FOR v IN OUTBOUND user GRAPH 'accounts'
FILTER IS_SAME_COLLECTION('partner', v)
RETURN v
Upvotes: 2