Creates a new map with multiple specified keys removed. The original map is not modified.
flex.map.removeKeys(map, keys)| Parameter | Type | Required | Description |
|---|---|---|---|
map |
map | Yes | The map to remove keys from |
keys |
list | Yes | An array of key names to remove |
Type: map (object)
A new map containing all properties from the input map except the specified keys. Returns an empty map if input is not a valid object.
WITH {name: 'Alice', age: 30, email: 'alice@example.com', password: 'secret'} AS user
RETURN flex.map.removeKeys(user, ['password', 'email']) AS sanitizedOutput:
sanitized
-----------------------
{name: 'Alice', age: 30}
MATCH (p:Product)
WITH properties(p) AS props
RETURN flex.map.removeKeys(props, ['internalId', 'createdBy', 'updatedAt']) AS publicMATCH (u:User {id: $userId})
WITH properties(u) AS allProps
WITH flex.map.removeKeys(allProps, ['password', 'salt', 'resetToken']) AS safeProps
RETURN safeProps AS userWITH {a: 1, b: 2, c: 3} AS map
RETURN flex.map.removeKeys(map, ['d', 'e']) AS resultOutput:
result
-----------------
{a: 1, b: 2, c: 3}
(Non-existent keys are ignored)
- Returns empty map if input is not a valid object or is
null nullvalues in the keys array are ignored- Keys that don't exist in the map are silently ignored
- Creates a new map; does not modify the original
- More efficient than calling
removeKeymultiple times - Useful for bulk removal of sensitive or internal fields
- map.removeKey - Remove a single key
- map.submap - Keep only specific keys (inverse operation)
- map.merge - Combine multiple maps