apoc.coll.containsAll
Syntax |
|
||
Description |
Returns whether or not all of the given values exist in the given collection (using a HashSet). |
||
Arguments |
Name |
Type |
Description |
|
|
The list to search for the given values in. |
|
|
|
The list of values in the given list to check for the existence of. |
|
Returns |
|
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 any()
WITH [1,2,3,4,5] AS mainList, [3,7] AS sublist
RETURN all (x IN sublist WHERE x IN mainList)
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)
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)
Output |
---|
true |