Comparing null to SET or REMOVE a node property ONLY when required

(Paul Drangeid) #1

I am querying a database to check for changed values vs my Nodes in my graph. I'm comparing several property values vs the entries in the ROW from the JDBC database query.
I want the property REMOVED if the row now has a null value
I want the property ADDED if the row now has a value
I want the property UPDATED if the row has a DIFFERENT value then the node.
I want NO write to happen if the row value and the node property value match.

I was looking at APOC, and thought apoc.atomic.update may work, but it seems you can only use the matching NODE for the expression (not a row from the JDBC results).
Here's the line that works, but I was looking to see if there was a more efficient procedure or function that accomplished the same results:

FOREACH (ignoreMe in CASE WHEN coalesce(t.service,'isnull') <> coalesce(row.USER1,'isnull') THEN [1] ELSE [] END | SET t.service=row.USER1)