Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Update Nodes and Relationships in Neo4J with Cypher


    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.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: 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.

    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.

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

    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.

    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.