问题
I have an array of multiple IDs of nodes to delete. Every Cypher example I can find either deletes one node or all nodes. How would one delete nodes that match an array of IDs, in a single query?
Something like this... (pseudocode):
MATCH (n:Node) WHERE (n.id in ['id_a', 'id_b']) DELETE n;
回答1:
You can use the IN list operator:
If id
is a property:
WITH [1,2,3,4] AS ids
MATCH (n) WHERE n.id IN ids
DETACH DELETE n;
If by id
you mean the internal node id:
WITH [1,2,3,4] AS ids
MATCH (n) WHERE id(n) IN ids
DETACH DELETE n;
来源:https://stackoverflow.com/questions/48121728/delete-several-nodes-in-neo4j