在neo4j中删除关系后如何返回值

时间:2019-09-30 06:47:20

标签: neo4j cypher

删除关系后如何返回节点和关系的值

密码:

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 节点确实存在。

1 个答案:

答案 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