I am using py2neo
to run a Cypher query in Python. Currently, I am passing the values of $user_id
and $name
.
query = "MATCH (user:User{id:$user_id, name: $name}) MATCH (user)-[rout]->() WITH user, collect(DISTINCT {relationship: type(rout), node: endNode(rout)}) AS extended_info RETURN { user: user, extended_info: extended_info } AS result"
graph.run(query, parameters= {"user_id": 1, "name": "Vivek"}).data()
Instead of just passing the values, I want to pass a dictionary of key and value. Something like this:
{id:1, name: "Vivek"}
And use it directly in the query. This will provide me with the flexibility to write a single query for filtering for one or multiple properties.
query = "MATCH (user:User{$params}) MATCH (user)-[rout]->() WITH user, collect(DISTINCT {relationship: type(rout), node: endNode(rout)}) AS extended_info RETURN { user: user, extended_info: extended_info } AS result"
graph.run(query, parameters= {id:1, name: "Vivek"}).data()
Is there a way to do it using py2neo
? Or is there any other way to write a single query for a match query?