[英]how to delete node and all related nodes not only the relations — neo4j cypher 1.8
how to delete node and all related nodes not only the relations For Example 如何删除节点与所有相关节点之间不仅有关系例如
account-[:GGroup]-group,
group-[:GEvent]-event,
group-[:GMember]-member,
group-[:GAlbum]-album,
album-[:GPhoto]-photo,
So I want to delete group with all related nodes (event and album( and photo)), this is my work ... I'm using java. 所以我想删除所有相关节点(事件和相册(和照片))的组,这是我的工作...我正在使用Java。
START group = node:GGroup('dbId:1')
MATCH group-[gp:privacy]-gPrivacy,
group-[gm:GroupMember]-(),
group-[ge:GroupEvent]-event,
event-[ep:privacy]-gePrivacy,
event-[eep:EventParticipant]-(),
event-[ea:EventAlbum]-eventAlbum,
eventAlbum-[ap:privacy]-geaPrivacy,
eventAlbum-[aph:AlbumPhoto]-eventAlbumPhoto,
eventAlbumPhoto-[ept:PhotoTag]-eventAlbumPhotoTag,
event-[ev:EventVideo]-eventVideo,
eventVideo-[vp:privacy]-gevPrivacy,
group-[ga:GroupAlbum]-groupAlbum,
groupAlbum-[gap:privacy]-gaPrivacy,
groupAlbum-[aphoto:AlbumPhoto]-groupAlbumPhoto,
groupAlbumPhoto-[gpt:PhotoTag]-groupAlbumPhotoTag,
group-[gf:GroupFile]-groupFile
delete group,gm,ge,event,ep,gePrivacy,eep,ea,eventAlbum,ap,geaPrivacy
,aph,eventAlbumPhoto,ept,eventAlbumPhotoTag,ev,eventVideo,vp,gevPrivacy,ga,
groupAlbum,gap,gaPrivacy,aphoto,groupAlbumPhoto,gpt,groupAlbumPhotoTag,gf,
groupFile,gp
START g=node({id_of_group_node})
MATCH acc-[ag:GGroup]-g
,g-[ge:GEvent]-e
,g-[gm:GMember]-m
,g-[ga:GAlbum]-a
,a-[ap:GPhoto]-p
DELETE g, ge, e, gm, m, ga, a, ap, p, ag
in case you want to delete all related nodes, there is no need to explicitly match them one by one in the MATCH phase. 如果要删除所有相关节点,则无需在MATCH阶段一一对应地明确匹配它们。 you can simply find all except the starting one (+ the album photos):
您可以简单地找到除起始图片(+相册照片)以外的所有图片:
START account=node(...)
MATCH account-[:GGroup]-group,
group-[r1]-all,
group-[:GAlbum]-()-[r2]-photo
WHERE Id(all)<>Id(account)
DELETE group, r1, all, r2, photo.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.