Skip to content

DELETE clause

wgevaert edited this page Apr 25, 2022 · 7 revisions

The DELETE clause accepts a list of variables to be deleted

Examples

$tomVariable = Query::variable("tom");
$tomNode = $tomVariable->withProperty('name', Query::literal('tom'))->labeled("Person");

$statement = Query::new()
	->match($tomNode)
        ->delete($tomVariable)
	->build();

$this->assertSame("MATCH (tom:Person {name: 'tom'}) DELETE tom", $statement);
$tomVariable = Query::variable("tom");
$tomNode = $tomVariable->withProperty('name', Query::literal('tom'))->labeled("Person");

$statement = Query::new()
        ->match($tomNode)
	->detachDelete($tomVariable)
	->build();

$this->assertSame("MATCH (tom:Person {name: 'tom'}) DETACH DELETE tom", $statement);
Clone this wiki locally