apoc.any.isDeleted

This function is not considered safe to run from multiple threads. It is therefore not supported by the parallel runtime. For more information, see the Cypher Manual → Parallel runtime.

Details

Syntax

apoc.any.isDeleted(object)

Description

Returns true if the given NODE or RELATIONSHIP no longer exists.

Arguments

Name

Type

Description

object

ANY

The node or relationship to check the non-existence of.

Returns

BOOLEAN

Example

Given this dataset:

CREATE (:Person {name: 'Alice'})-[:KNOWS]->(:Person {name: 'Bob'})

The following query checks whether a node and relationship are deleted, both before and after a DETACH DELETE within the same transaction:

MATCH (a:Person {name: 'Alice'})-[r:KNOWS]->()
WITH
  a,
  r,
  apoc.any.isDeleted(a) AS beforeDeleteNode,
  apoc.any.isDeleted(r) AS beforeDeleteRel
DETACH DELETE a
RETURN
  beforeDeleteNode,
  beforeDeleteRel,
  apoc.any.isDeleted(a) AS afterDeleteNode,
  apoc.any.isDeleted(r) AS afterDeleteRel
Results
beforeDeleteNode beforeDeleteRel afterDeleteNode afterDeleteRel

false

false

true

true

Before the delete, both the node and relationship still exist, so the function returns false. After DETACH DELETE a, both have been removed and the function returns true.