Book Image

Building web applications with Python and Neo4j

By : Sumit Gupta
Book Image

Building web applications with Python and Neo4j

By: Sumit Gupta

Overview of this book

Table of Contents (14 chapters)
Building Web Applications with Python and Neo4j
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Transforming nodes and relationships


In this section, we will discuss updating labels, properties, and relationships.

Updating node properties

The properties of a node are modified by using the following Cypher statement:

MATCH (f:FEMALE {name: "Sheena"})
SET f.surname = "Foster"
return f;

The preceding statement will find the node Sheena and will add or update (if it already exists) the property surname with a new or modified value. For removing the property, just replace the SET statement in the preceding Cypher query with SET f.surname = NULL. We can also set multiple properties by separating them with a comma.

The REMOVE statement is another construct provided by Cypher for removing the properties of a node. For example, we can also execute the following statement for removing the property surname:

MATCH (f:FEMALE {name: "Sheena"})
REMOVE f.surname
return f;

Updating a label

Labels can also be updated in the same fashion as node properties. Continuing our previous example, let's add one more...