No, Cypher does not support Optional parameters in queries.
However, we can use an alternative solution to provide similar functionality.
We can use coalesce() to supply a default for a limited value, and the limit value can be provided by a parameter, but we cannot directly have an optional parameter.
We CAN get the equivalent by using a parameter map, where the limit we want to refer to is an element in the map:
:param {limit: {value:5}}
MATCH (n)
RETURN n
LIMIT coalesce(toInteger($limit.value), 10)
The $limit parameter MUST EXIST and be passed in...but it could be an empty map, or it could have a value entry in its map. That allows us the flexibility to treat it as optional.
Comments
0 comments
Please sign in to leave a comment.