I need to create a relationship between two newly created nodes,but it's creating another two nodes without creating a relationship between them. I need to know how to get data from py2neo
cypher
query
def enter_products():
if request.method == 'POST':
data = request.get_json(True)
params = {"data": {"name":data['name']}}
products=graph.cypher.execute(" create(a:Products {data}) RETURN (a)", params)
CR_brand= {"data": {"brand":data['brand']}}
brands=graph.cypher.execute("merge(b:Brand {brand:{data}.brand})
RETURN (b)",CR_brand)
relation_brand=graph.cypher.execute("create(a:name)-[c:product_of]->(b:brand)")
RETURN 'OK'
You either can do it all in one statement:
create(a:Products {data})
merge(b:Brand {brand:{data}.brand}
create(a)-[:product_of]->(b)
or you have to look up by their key-property.
create(a:Products {name:{data}.name})-[c:product_of]->(b:Brand {data}.brand)
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.