-
Notifications
You must be signed in to change notification settings - Fork 5
REMOVE clause
Marijn van Wezel edited this page Dec 15, 2022
·
5 revisions
The REMOVE
clause is used to remove properties from nodes and relationships, and to remove labels from nodes.
Query::remove(Label|Property|(Label|Property)[] $expressions): Query
-
$expressions
: A single property or label to remove, or a non-empty list of properties and labels to remove.
-
addExpression(Label|Property ...$expressions): self
: Add one or more labels and properties to remove.
$a = node()->withProperties(['name' => 'Andy']);
$query = query()
->match($a)
->remove($a->property('age'))
->returning([$a->property('name'), $a->property('age')])
->build();
$this->assertStringMatchesFormat("MATCH (%s {name: 'Andy'}) REMOVE %s.age RETURN %s.name, %s.age", $query);
$n = node()->withProperties(['name' => 'Peter']);
$query = query()
->match($n)
->remove($n->labeled('German'))
->returning($n->property('name'))
->build();
$this->assertStringMatchesFormat("MATCH (%s {name: 'Peter'}) REMOVE %s:German RETURN %s.name", $query);
$n = node()->withProperties(['name' => 'Peter']);
$query = query()
->match($n)
->remove($n->labeled('German', 'Swedish'))
->returning($n->property('name'))
->build();
$this->assertStringMatchesFormat("MATCH (%s {name: 'Peter'}) REMOVE %s:German:Swedish RETURN %s.name", $query);