Reputation: 47
How do I trigger an action to be performed (set the property to something) on a node after a particular time in neo4j?
I know about the graphaware's neo4j-expire, but it only deletes nodes or relationships when the time is up, which is not what I want?
Upvotes: 1
Views: 188
Reputation: 29147
You can use a combination of apoc.date.expireIn and apoc.trigger procedures. For example first add trigger:
CALL apoc.trigger.add('doVertexTask', '
UNWIND {deletedRelationships} AS dRel
WITH dRel WHERE type(dRel) = "taskRelation"
WITH endNode(dRel) AS vertexNode WHERE "Vertex" IN labels(vertexNode)
SET vertexNode.prop = rand()
RETURN true',
{phase: "before"})
Then add the data and task:
MERGE (A:Vertex {id: 1})
CREATE (T:TASK)
CREATE (T)-[:taskRelation]->(A)
WITH A, T
CALL apoc.date.expireIn(T, 10, 's')
RETURN A, T
Upvotes: 1