Reputation: 5116
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;
Upvotes: 2
Views: 1003
Reputation: 8556
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;
Upvotes: 5