0

What would be the best way to go if I want to create an AMQP message every time a specific node is inserted/deleted from the graph? I looked into trigger events but they are only capable of Cypher so I can trigger a simple python/go/c++ script or am I wrong?

Moraltox
  • 537
  • 1
  • 7

1 Answers1

1

You can create a custom query module that will be called on a trigger. This is just an example but you can continue from it:

A custom query module in Python looks like this:

import mgp

@mgp.read_proc
def hello_procedure(context: mgp.ProcCtx, node: mgp.Vertex) -> mgp.Record():
  // Do something with the vertex or the whole graph db context
  return mgp.Record()

And then calling this on a node created trigger:

CREATE TRIGGER on_create ON () CREATE
AFTER COMMIT EXECUTE 
UNWIND createdVertices AS createdVertex
CALL mymodule.hello_procedure(createdVertex) YIELD * RETURN *;
Taja Jan
  • 942
  • 1
  • 1
  • 11