简体   繁体   中英

creating dynamic updates in Agensgraph via Cypher

trying to create a function like:-

addChild(parent graphid,child graphid,relationship text,direction text)

merge(parent)-[r:f(relationship)]->(child) return id(r);

with a typical cal:

relid=addChild(id(a),id(b),'has','U') -- where U means up child to parent

Question is, without a very tedious switch statement, how do I associate a text version of the relationship, or edge type, with an actual edge type?

Took a bit of messing around and the syntax seems a bit last-minute but this works:

return query execute format('match(p) where id(p)=%s with p match(c) where id(c)=%s with p,c merge(p)-[r:%s]->(c)  return id(r);',parent,child,reltype);

Where parent and child are graph ids and reltype is text;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM