Reputation: 687
I have Players and Games nodes types .... player can invite other player to a game.
once a player A will invite player B it will look like that:
A-[:INTERACT]->game<-[:INTERACT]-B , game.initiator = ID(A) , game.state = 'INVITE'
As you can see I am using a property inside the game to represent whom invited whom.
game can be in many states.
for a given player I need a query to retrieve all his games except this which in state = INVITE and he initiate them.
Tried the following but without success even though it sound like easy case:
START playerA = node()
match playerA-[:INTERACT]->game<-[:INTERACT]-otherPlayer
where not(game.state = 'INVITE' and game.initiator = ID(playerA))
return game
for example:
http://console.neo4j.org/r/fkpoht
START playerB = node(15)
MATCH playerB-[:INTERACT]->game<-[:INTERACT]-PlayerA
WHERE NOT (game.state = 'INVITE' AND game.initiator = ID(playerB))
RETURN game
Why the above query doesn't return the game? the first condition is true the sec is false not(true&false) = true...
What is the way to do this simple query right? your answer are highly appreciated.
Upvotes: 2
Views: 12368
Reputation: 19373
What about
START playerA = node(1)
MATCH playerA-[:INTERACT]->game<-[:INTERACT]-otherPlayer
WHERE (game.state='INVITE' AND game.initiator <> 1) OR (game.state<>'INVITE')
RETURN game
Upvotes: 2
Reputation: 1053
In case you need to retrieve all his games, which he initiate them and state not INVITE
:
START playerA = node()
MATCH playerA-[:INTERACT]->game<-[:INTERACT]-otherPlayer
WHERE (game.initiator = ID(playerA)) AND NOT (game.state = 'INVITE')
RETURN game
Upvotes: 1