Creating objects is not sufficient for a database to be useful. It also needs to be able to do the following:
- Update existing objects with new information
- Delete objects that are no longer relevant
- Read data from the database
This section deals with the first two bullet points, while the last one will be covered in the following section.
Updating objects
There is no UPDATE keyword with Cypher. To update an object, node, or relationship, we'll use the SET statement only.
Updating an existing property or creating a new one
If you want to update an existing property or add a new one, it's as simple as the following:
MATCH (n {id: 1})
SET n.name = "Node 1"
RETURN n
The RETURN statement is not mandatory, but it is a way to check the query went well, for instance, checking the Table tab of the result cell:
{
"name": "Node 1",
"id": 1
}
Updating all properties of the node
If we want to update all...