apoc.map.mget
Function APOC Core
apoc.map.mget(map,key,[defaults],[fail=true]) - returns list of values for keys or throws exception if one of the key doesn’t exist and no default value given at that position
Signature
apoc.map.mget(map :: MAP?, keys :: LIST? OF STRING?, values = [] :: LIST? OF ANY?, fail = true :: BOOLEAN?) :: (LIST? OF ANY?)
Input parameters
Name | Type | Default |
---|---|---|
map |
MAP? |
null |
keys |
LIST? OF STRING? |
null |
values |
LIST? OF ANY? |
[] |
fail |
BOOLEAN? |
true |
Usage Examples
The following returns a list of values for keys name
and country
:
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map
RETURN apoc.map.mget(map, ["name", "country"]) AS output;
Output |
---|
["Cristiano Ronaldo", "Portugal"] |
The following returns a list of values for keys name
and country
, and default value defaultValue
for missing key missingKey
:
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map
RETURN apoc.map.mget(
map,
["name", "country", "missingKey"],
[null, null, "defaultValue"]
) AS output;
Output |
---|
["Cristiano Ronaldo", "Portugal", "defaultValue"] |