apoc.map.mget
Function
apoc.map.mget(map Map<String, Any>, keys [String], values [Any], fail Boolean)
- returns a list of values for the given keys.
If one of the keys does not exist, or lacks a default value, this function will throw an exception.
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"] |
Was this page helpful?