Neo4j删除与跳过和订购

时间:2016-10-09 12:57:45

标签: neo4j cypher

我需要删除所有带有User标签的节点,其上设置了属性deactivated,但最近创建的20个节点除外。

检索它们很简单:

MATCH (x:User {deactivated: true}) RETURN x ORDER BY x.created_at DESC SKIP 20

什么是等效的删除声明?

1 个答案:

答案 0 :(得分:3)

RETURN语句替换为WITH,并将结果传递给DETACH DELETE

MATCH (x:User {deactivated: true}) 
WITH x 
ORDER BY x.created_at DESC 
SKIP 20
DETACH DELETE x