neo4j条件中的语法无效

时间:2014-12-20 14:23:13

标签: neo4j cypher

如果节点没有关系并返回true,我想删除节点,否则返回false

match (p:Type {id:72})-->(x)
RETURN 
CASE count(x)
WHEN 0 THEN DELETE p 'true'
ELSE 'false'
END AS deleted;

我总是得到无效的语法。这在密码中是否可行?

2 个答案:

答案 0 :(得分:1)

或者

match (p:Type {id:72})
where not exists ((p)--())
delete p

答案 1 :(得分:0)

要查找没有关系的节点,您需要使用OPTIONAL MATCH并在WITH之后检查空值:

match (p:Type {id:72})
optional match (p)-[r]-()
with p, r
where r IS null
delete p