Update labels
To add or remove labels to a node, use .set and .remove with the node method .label.
Add labels
const movie = new Cypher.Node();
const clause = new Cypher.Match(new Cypher.Pattern(movie)).set(movie.label("NewLabel"), movie.label("Another label"));
MATCH (this0)
SET
this0:NewLabel,
this0:`Another Label`
Remove labels
const movie = new Cypher.Node();
const clause = new Cypher.Match(new Cypher.Pattern(movie)).remove(movie.label("NewLabel"));
MATCH (this0)
REMOVE this0:NewLabel
Set dynamic labels
In some cases, the labels to add or remove must be defined dynamically, such as the result of an expression.
To achieve this, the .label methods accepts an expression instead of a string.
For example, to copy all the labels from one node to another, the function labels() can be used as the expression to .label:
new Cypher.Match(new Cypher.Pattern(movie)).set(movie.label(Cypher.labels(anotherNode)));
This correctly applies the syntax for dynamic labels:
MATCH (this0)
SET
this0:$(labels(this1))