0
votes

If I have a cypher query like:

MATCH (user:USER)
WHERE user.userName = {userName}
RETURN user

I return the whole user object if a user exists with a matching username. If all I care about is if the user exists or not is there a way to return something that signals existence of a matching node? (this will cut down on data transfer if nothing else)

1

1 Answers

0
votes

Would something like this do what you want?

MATCH (user:User {userName:{userName}})
RETURN 1 = count (user) as exists

or, if "exist" includes cases with more than one matching node

RETURN 0 < count (user) as exists

or just

RETURN count (user) as cnt