Pass Parameters to Queries
Learn how to query graphs with parameters using Cypher.
Why query with parameters?
Cypher supports querying with parameters. This simplifies query reuse and makes caching of execution plans easier, in turn leading to faster query execution times.
Parameters as map
The Bolt.Sips
module allows us to pass our parameters as a map in a third argument to the query/3
function. (The first argument is the database connection, and the second is the query string.)
But the query functions we have created so far just take the query string and implicitly supply the database connection. We need to do something about that.
Parameters support
Let’s add some functionality to support querying with parameters.
Add callbacks
We’ll first update the GraphCommons.Service
behavior with a couple of optional callbacks:
Get hands-on with 1200+ tech skills courses.