cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Conditional apoc.map.setKey

nikolai
Node Link

Hi!

I was trying to conditionally set a key using apoc.map.setKey but am not getting it to work.
How would I go about doing something like

if value.selection is not null
apoc.map.setKey(n, 'who', {filter: value.selection, type: type})

Any hints would be very much appreciated!

Nikolai

1 ACCEPTED SOLUTION

You can use WHERE for a general filter or perhaps CASE

WITH CASE value.selection WHEN null THEN map ELSE apoc.map.setKey(map, 'who', {filter: value.selection, type: type}) END as map

View solution in original post

2 REPLIES 2

You can use WHERE for a general filter or perhaps CASE

WITH CASE value.selection WHEN null THEN map ELSE apoc.map.setKey(map, 'who', {filter: value.selection, type: type}) END as map

Thanks a lot! This works well!