Sean Saito
Sean Saito

Reputation: 675

Updating all properties of a node (Neo4j)

I am referring to the "Set all properties using a parameter" section of this page in the docs: http://neo4j.com/docs/stable/query-set.html

It says that I can set all properties of a node using a json format like this:

{
    "props" : {
        "name" : "Andres",
        "position": "Developer"
     }
}

with the query:

MATCH (n { name: 'Andres' })
SET n = { props }
RETURN n

This is not working in cypher. Is this only for the RESTful API? To be specific, I am making cypher queries via a Python app.

Upvotes: 1

Views: 988

Answers (1)

Nicole White
Nicole White

Reputation: 7790

Any of the Python clients should support passing in a dictionary for a parameter to set all properties. In py2neo, for example:

from py2neo import Graph
graph = Graph()
graph.cypher.execute("CREATE (n:Person) SET n = {props} RETURN n", props={"x":1,"y":2})

   | n                    
---+-----------------------
 1 | (n6:Person {x:1,y:2})

Upvotes: 2

Related Questions