apoc.map.cleanFunctionDeprecated in Cypher 25
|
This function is deprecated. Use Cypher’s map comprehension instead. |
Syntax |
|
||
Description |
Filters the keys and values contained in the given |
||
Arguments |
Name |
Type |
Description |
|
|
The map to clean. |
|
|
|
The list of property keys to be removed. |
|
|
|
The list of values to be removed. |
|
Returns |
|
||
Usage examples
The following removes empty string values from a map:
apoc.map.clean
WITH {name: "Cristiano Ronaldo", club: ""} AS map
RETURN apoc.map.clean(map, [], [""]) AS output;
Cypher’s Map Comprehension
WITH {name: "Cristiano Ronaldo", club: ""} AS map
RETURN { k: v IN map WHERE v <> "" | k: v } AS output;
| Output |
|---|
{
"name": "Cristiano Ronaldo"
}
|
The following removes empty string values and the keys dob and country from a map:
apoc.map.clean
RETURN apoc.map.clean(
{name:"Cristiano Ronaldo", country:"Portugal", dob:date("1985-02-05"), club: ""},
["dob", "country"],
[""]
) AS output;
Cypher’s Map Comprehension
WITH {name:"Cristiano Ronaldo", country:"Portugal", dob:date("1985-02-05"), club: ""} AS map,
["dob", "country"] AS keys
RETURN { k: v IN map WHERE NOT k IN keys AND k <> "" | k: v } AS output;
| Output |
|---|
{
"name": "Cristiano Ronaldo"
}
|