I have a use case where
Create new node if there is no node with given id
Return existing node if node exists with given id
return null if given id is null
Ex: User({emailId: 'x.com'})
If email id is null, then it should return null
I have a use case where
Create new node if there is no node with given id
Return existing node if node exists with given id
return null if given id is null
Ex: User({emailId: 'x.com'})
If email id is null, then it should return null
merge
MERGE - Cypher Manual will do create if not exists otherwise return but does not account for if null.
For example
merge (n: User({emailId: 'x.com'}) return n;
will create the node and then return the node if it the node does not already exist and if the node already exists it will simply return the node and not create a new node.
Note the documentation link above refers to Neo4j 4.2 documentation. It should be the same for all versions of Neo4j but as the initial problem description provided no version details
There is a problem with syntax of your merge statement.
solved this way
foreach(
managerEmailId in CASE when ${'$'}managerEmailId IS NOT NULL THEN[${'$'}managerEmailId] ELSE [] END |
merge (u)<-[:IS_MANAGER_OF]-(:User {email_id : managerEmailId, tenant_id: ${'$'}tenantId})
)
with u