Want to know the difference between apoc.do.case and apoc.do.when

Hello team,

I want to know the difference between apoc.do.case and apoc.do.when APOC's.
Also let me know which of the above is used in which scenarios.

Best Regards
Akshat

apoc.do.when() is similar to an if/else conditional based on a single evaluated boolean expression, so there can be only two outcomes, with the ability to supply a Cypher query to execute in each of those two cases.

apoc.do.case() is more similar to a case statement, in that you can have several boolean conditions to evaluate, executing the Cypher associated with only the first one that evaluates to true (or falling back on the else conditional if none of the evaluated conditions is true).

1 Like