⚠️ This lesson is retired and might contain outdated information.

Update Nodes and Relationships in Neo4J with Cypher

Matt Ross
InstructorMatt Ross
Share this video with your friends

Social Share Links

Send Tweet

The data in our graph is unlikely to stay the same forever. We will cover the syntax used to find and modify existing data in different ways through the use of parameters.

Instructor: [00:00] Once we are able to create and read data from our Neo4j graph, we can use the same concepts to update our nodes. It's also possible to represent the changes using a collection of values or parameters. When using Neo4j Desktop, these are set with the params keyword.

[00:19] We can also update our node by setting all of our parameters and leaving the existing ones intact with the += operator, or we could replace all of the current properties with those in our parameters with the = operator. This will have the effect of removing Luke's gender property.

[00:39] We can also use REMOVE to remove any properties we have set on a node. Let's remove Luke's eye color.

[00:47] Cypher also provides us with a MERGE clause, which we can think of as sugar, over MATCH and an optional CREATE. This will either create or match an existing node, with the value of name set to R2-D2.

[00:59] Along with MERGE, we can use ON MATCH SET and ON CREATE SET if we want the two operations to behave differently depending on whether we match an existing node or create a new one.