So far, there is no node exists cypher statement in Neo4j. At some scenario, you might want to test if a with specific property exists or not. In this case, here is the cypher statement can be used to verify is a node exist:
OPTIONAL MATCH (n:Person {name: 'Tom Hanks'})
RETURN n IS NOT NULL AS Predicate
So why are we using OPTIONAL MATCH
, what does OPTIONAL MATCH
means?
OPTIONAL MATCH
matches patterns against your AuraDB Instance, just like MATCH
does. The difference is that if no matches are found, OPTIONAL MATCH
will use a null
for missing parts of the pattern. OPTIONAL MATCH
could be considered the Cypher equivalent of the outer join in SQL.
OPTIONAL MATCH (p:Person {id:123})
WITH p
RETURN p.name
ref: https://neo4j.com/docs/cypher-manual/current/clauses/optional-match/
Comments
0 comments
Please sign in to leave a comment.