apoc.map.setPairsFunction
Syntax |
|
||
Description |
Adds or updates the given key/value pairs (e.g. [key1,value1],[key2,value2]) in a |
||
Arguments |
Name |
Type |
Description |
|
|
The map to be updated. |
|
|
|
A list of pairs to add or update the map with. |
|
Returns |
|
||
Usage Examples
The following updates a key in a map:
Cypher’s map comprehension
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map,
{pair IN [["dob", date("1986-02-06")], ["country", "Spain"]] | pair[0] : pair[1]} AS updates
RETURN {k IN keys(map) + keys(updates) | k : CASE WHEN k IN keys(updates) THEN updates[k] ELSE map[k] END} AS output
apoc.map.setPairs
RETURN apoc.map.setPairs(
{name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")},
[ ["dob", date("1986-02-06")],
["country", "Spain"]
]
) AS output
| Output |
|---|
|