I have a couple of nodes. A user and a post. I want to add a like relationship between the user and the post (user-[LIKE]->post) only if the like does not already exist. This query does the trick
START u=node:node_auto_index(UserIdentifier = 'USER12'), p=node:node_auto_index(PostIdentifier = 'USER5POST4')
MATCH u-[existingLike?:LIKE]->p
WHERE existingLike IS NULL
CREATE u-[l:LIKE]->p
RETURN u, l, p;
In my service call I want to know if the user exists, the post exists and if the new like has been added. This part works only OK when the new like is added as I get (u, l and p) return values. When there is an existing like or the user or post is missing I get no return values.
Is there a way to return u and p using only one Cypher query whether or not the create statement executed?