neo4j / cypher : delete double linked list in one request -


using neo4j, have done implementation of newsfeeds each users. using double linked list 2 kind of relation "next_activity" / "prev_activity". on each activity node can have others relations "like". when delete user in system delete news feeds. have iterate each activity, delete (and relations like) , able go next using relation "next_activity".

does possible using cypher in 1 request (i mean using *..100 option).

thank you!


i have tried (version 1.8.2) :

    start user=node:id(id="...") match  path=user-[r:next|prev|likes*]->activity     relationships(path) act_r, nodes(path) act_n     foreach(r in act_r : delete r)     act_n     foreach(n in act_n : delete n); 

but have 'transactionfailureexception"

i going test on 1.9.2 rc2

i think should work:

start user=node... // lookup user in index match p=user-[:next*]-activity // find activities nodes in linked list nodes(p) activities // includes user foreach activity in activities:    match activity-[r?]-() // relationships coming off of each activity   delete activities, r; // delete each activity 

update: new idea. i'll leave other idea there posterity. should work because should match each path until end, , we'll use endpoint delete :like relationships (or relationship) going off of those.

start user=node... // lookup user in index match p=user-[:next*]-activity, activity-[r?]-() delete user, activity, r; 

i built graph , tested it, think should general solution.

http://console.neo4j.org/?id=nnj5h8


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -