删除关系后如何返回节点和关系的值
密码:
MATCH (p:Person)-[t:LIKED]->(a:Post) WHERE p.identity='kOo08cpMoYPWwnwB4XMZ3CbTRcO2' AND a.uuid='b60f773d-6d85-48bc-9900-8037c4b2c0b2' DELETE t WITH p,a MATCH (a)<-[l:LIKED]-() RETURN count(l) AS likes, exists((p)-[:LIKED]->(a)) AS liked, a.uuid AS uuid
上面的查询始终返回[]
, p 和 a 节点确实存在。
答案 0 :(得分:1)
好像第二个MATCH
找不到任何匹配项。尝试使用OPTIONAL MATCH
语句:
MATCH (p:Person)-[t:LIKED]->(a:Post)
WHERE p.identity='kOo08cpMoYPWwnwB4XMZ3CbTRcO2' AND a.uuid='b60f773d-6d85-48bc-9900-8037c4b2c0b2'
DELETE t
WITH p,a
OPTIONAL MATCH (a)<-[l:LIKED]-()
RETURN count(l) AS likes, exists((p)-[:LIKED]->(a)) AS liked, a.uuid AS uuid