在neo4j中特定时间后,如何触发要在节点上执行的操作(将属性设置为某物)?
我了解graphaware's neo4j-expire,但是它只在时间到了时才删除节点或关系,这不是我想要的吗?
答案 0 :(得分:0)
您可以结合使用apoc.date.expireIn和apoc.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"})
然后添加数据和任务:
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