I have created trigger when property of node will update, But i want to log that updated properties or create Log node to store this updated Properties with old Key Values and new Key Values...
This is my APOC trigger
`CALL apoc.trigger.add('setLastUpdate',
'UNWIND keys($assignedNodeProperties) as k
UNWIND $assignedNodeProperties[k] AS map
with map.node as node, collect(map.key) as propertyList
match (n)
WHERE id(n) = id(node) AND NOT "lasts" in propertyList
@michael.hunger
As per you said i have replaced afterAsync by after and its working
But when i try to update more than one property it created two Log nodes
//Apoc Trigger to update values
<CALL apoc.trigger.add('setLastUpdate',
'UNWIND keys($assignedNodeProperties) as k
UNWIND $assignedNodeProperties[k] AS prop
with prop.node AS node, prop.key AS key, prop.old AS oldValue, prop.new AS newValue
I am new on neo4j i don't know how to handle this old and updated values
i stuck here from last two days..
please provide me code snippet so i can create single Log label with all properties.
use MERGE instead of CREATE and create a constraint on Log(nodeId) or use the transaction-id as id.
merge (log:Log{nodeId:elementId(node)})
set log += {
timestamp:timestamp(),
name:"Log", // you probably don't need that as you have the label
nVal:newValue,
key:key,
oldVal:oldValue}
return log
As per you said to add constraint on Log (nodeId)
I tried your solution and its working
But I have one more concern that is when I am trying to set more than two values then these Log node shows only last values.
`CALL apoc.trigger.add('setLastUpdate',
'UNWIND keys($assignedNodeProperties) as k
UNWIND $assignedNodeProperties[k] AS prop
with prop.node AS node, prop.key AS key, prop.old AS oldValue, prop.new AS newValue