neo4j - How to delete nodes under a hierarchy in a single query -


i have challenge node can have comments posted under it. each comment node can in turn have comments posted under it, level.

visually, in image below:

enter image description here

when challenge node deleted, need able first delete entire hierarchy of comment nodes attached challenge node.

i've tried few queries not able figure out how use single query achieve effect. 1 query i'm trying deletes nodes @ level 2 is:

match (c:challenge {id: 'rjksss-4w'})<-[:posted_in]-(comment:comment)  c, comment  optional match (comment)<-[:posted_in]-(childcomment)  detach delete childcomment; 

is there way write single query, can delete comment nodes posted under challenge node (including @ level 1, 2, ... )? in example illustrated above, 13 comment nodes deleted in single query.

try

match (c:challenge {id: 'rjksss-4w'})<-[:posted_in*]-(comment:comment) detach delete comment 

i would've commented don't have enough reputation


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -