How to change / update a shortcut in Neo4j - Cypher?

Is it possible to change the label to node using Cypher? I have a node with a label Bookas shown below. I want to change the label Bookto DeletedBook.

(u:Person)-[r]-(b:Book{id:id1})

(u:Person)-[r]-(b:DeletedBook{id:id1})
+5
source share
2 answers

You can do this using REMOVEon the shortcut Bookand SETon the new shortcut:

MATCH (p:Person)-[r]-(b:Book {id: id1})
REMOVE b:Book
SET b:DeletedBook
RETURN b

You should check out the Neo4j Cypher Refcard for a full reference to Cypher 2.x.

+10
source

You can use "REMOVE" to delete and SET to add a new label.

eg:

MATCH (p:Person)-[r]-(b:Book {id: id1})
REMOVE b:Book
SET b:DeletedBook
RETURN b

"" , . .

MATCH (p:Person)-[r]-(b:Book {id: id1})
SET b: Deleted
RETURN b

2 (: : )

0

Source: https://habr.com/ru/post/1543372/


All Articles