'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?
Solution 1:[1]
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;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Reza Rahemtola |
