We briefly talked about NULL values in the previous chapter. In Neo4j, NULL values are not saved in the properties list. An absence of a property means it's null. So, deleting a property is as simple as setting it to a NULL value:
MATCH (n {id: 1})
SET n.age = NULL
RETURN n
Here's the result:
{
"name": "Another name",
"address": "Earth, Universe",
"id": 1,
"gender": "F" }
The other solution is to use the REMOVE keyword:
MATCH (n {id: 1})
REMOVE n.address
RETURN n
The result would be as follows:
{
"gender": "F",
"name": "Another name",
"id": 1
}
If you want to remove all properties from the node, you will have to assign it an empty map like so:
MATCH (n {id: 2})
SET n = {}
RETURN n