apoc.coll.containsAll

This function is deprecated. Use Cypher’s all() function instead.

Details

Syntax

apoc.coll.containsAll(coll1, coll2)

Description

Returns whether or not all of the given values exist in the given collection.

Arguments

Name

Type

Description

coll1

LIST<ANY>

The list to search for the given values in.

coll2

LIST<ANY>

The list of values in the given list to check for the existence of.

Returns

BOOLEAN

Usage examples

The following examples checks if a collection contains all the values from another collection using both APOC and Cypher:

apoc.coll.containsAll
WITH [1,2,3,4,5] AS mainList, [3,7] AS sublist
RETURN apoc.coll.containsAll(mainList, sublist) AS output
Cypher’s all()
WITH [1,2,3,4,5] AS mainList, [3,7] AS sublist
RETURN all(x IN sublist WHERE x IN mainList) AS output
Results
Output

false

apoc.coll.containsAll
WITH [1,2,3,4,5] AS mainList, [1,3] AS sublist
RETURN apoc.coll.containsAll(mainList, sublist) AS output
Cypher’s all()
WITH [1,2,3,4,5] AS mainList, [1,3] AS sublist
RETURN all(x IN sublist WHERE x IN mainList) AS output
Results
Output

true

apoc.coll.containsAll
WITH [1,2,3,4,5] AS mainList, [4,1] AS sublist
RETURN apoc.coll.containsAll(mainList, sublist) AS output
Cypher’s all()
WITH [1,2,3,4,5] AS mainList, [4,1] AS sublist
RETURN all(x IN sublist WHERE x IN mainList) AS output
Results
output

true