The SET clause is used to update property values on existing nodes and edges. It is always used in combination with a MATCH clause that identifies the entities to update.
- Cypher
- Python SDK
// Update a single property
MATCH (n:Person {name: 'Alice'})
SET n.age = 30
// Commit the changes
COMMITSetting a single property
To update a property on a node or edge, use SET followed by a property assignment.
MATCH (n:Person {name: 'Alice'})
SET n.age = 30This sets the age property of the matched node to 30. If the property does not already exist, it will be created.
Setting multiple properties
Multiple properties can be updated in a single SET clause by separating assignments with commas.
MATCH (n:Person {name: 'Alice'})
SET n.position = 'Developer', n.surname = 'Taylor'Setting a property from an expression
The value assigned can be any expression, including arithmetic operations on existing properties.
MATCH (p:Product)
SET p.discountPrice = p.price * (1 - 0.15)Setting a property from another variable
You can copy a property value from one matched entity to another.
MATCH (n:Person {name: 'Alice'}), (m:Person {name: 'Bob'})
SET n.age = m.ageUpdating edge properties
Edge properties can be updated using the same syntax.
MATCH (n:Person {name: 'Alice'})-[e:KNOWS]->(m:Person {name: 'Bob'})
SET e.since = 2020Updating a specific node by internal ID
Every node in TuringDB has an internal ID. You can target a specific node by comparing it directly to its ID in a WHERE clause. This is useful when you already know the exact node you want to update.
MATCH (n)
WHERE n = 1234
SET n.age = 42Using SET with WHERE
SET can be combined with WHERE to update properties on nodes that match a condition.
MATCH (n:Person)
WHERE n.age < 18
SET n.isMinor = trueCREATE ... SET is not supported. When creating nodes or edges, use brace initialisation to set properties directly in the CREATE clause:
CREATE (:Person {name: 'Alice', age: 30})# Update a single property
client.query("MATCH (n:Person {name: 'Alice'}) SET n.age = 30")
# Commit the changes
client.query("COMMIT")Setting a single property
To update a property on a node or edge, use SET followed by a property assignment.
client.query("MATCH (n:Person {name: 'Alice'}) SET n.age = 30")This sets the age property of the matched node to 30. If the property does not already exist, it will be created.
Setting multiple properties
Multiple properties can be updated in a single SET clause by separating assignments with commas.
client.query("MATCH (n:Person {name: 'Alice'}) SET n.position = 'Developer', n.surname = 'Taylor'")Setting a property from an expression
The value assigned can be any expression, including arithmetic operations on existing properties.
client.query("MATCH (p:Product) SET p.discountPrice = p.price * (1 - 0.15)")Setting a property from another variable
You can copy a property value from one matched entity to another.
client.query("""
MATCH (n:Person {name: 'Alice'}), (m:Person {name: 'Bob'})
SET n.age = m.age
""")Updating edge properties
Edge properties can be updated using the same syntax.
client.query("""
MATCH (n:Person {name: 'Alice'})-[e:KNOWS]->(m:Person {name: 'Bob'})
SET e.since = 2020
""")Updating a specific node by internal ID
Every node in TuringDB has an internal ID. You can target a specific node by comparing it directly to its ID in a WHERE clause. This is useful when you already know the exact node you want to update.
client.query("""
MATCH (n)
WHERE n = 1234
SET n.age = 42
""")Using SET with WHERE
SET can be combined with WHERE to update properties on nodes that match a condition.
client.query("""
MATCH (n:Person)
WHERE n.age < 18
SET n.isMinor = true
""")CREATE ... SET is not supported. When creating nodes or edges, use brace initialisation to set properties directly in the CREATE clause:
client.query("CREATE (:Person {name: 'Alice', age: 30})")
