Search code examples
neo4jcypherpy2neo

LIST as parameter in 'run' query


My code should create a set of nodes whose payload should be represented by an arbitrary length array . In other words, this should look like

(n:Node {array:...})

While it's easy to pull that off with a dictionary like so

"MATCH (n) SET n+={param}",param=dict

I'm totally at a loss as to how that can be done with a list - especially, one of a length that will only be known at runtime.

I am thinking of embedding a list in a dictionary, but isn't there a more elegant way of doing that?

Thanks!


Solution

  • The easiest way to set an array is to just do this:

    "MATCH (n) SET n.array = $param", param=list
    

    NOTE: I used the $param syntax instead of {param}, as the latter is deprecated.