apoc.convert.toRelationshipList

Details

Syntax

apoc.convert.toRelationshipList(relList)

Description

Converts the given value into a LIST<RELATIONSHIP>.

Arguments

Name

Type

Description

relList

ANY

The value to convert into a relationship list.

Returns

LIST<ANY>

Example

Given this dataset:

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

The following query uses apoc.convert.toRelationshipList to cast a generic list to a LIST<RELATIONSHIP>:

MATCH ()-[r:KNOWS]->()
WITH collect(r) AS rels
RETURN apoc.convert.toRelationshipList(rels) AS relationships
Results
relationships

[[:KNOWS], [:KNOWS]]