Skip to content

Instantly share code, notes, and snippets.

View mayrsascha's full-sized avatar
🏠
Working from home

Sascha Mayr mayrsascha

🏠
Working from home
View GitHub Profile
@goliatone
goliatone / README.md
Last active September 24, 2024 23:15 — forked from colophonemes/create_triggers
Postgres TRIGGER to call NOTIFY with a JSON payload

This TRIGGER function calls PosgreSQL's NOTIFY command with a JSON payload. You can listen for these calls and then send the JSON payload to a message queue (like AMQP/RabbitMQ) or trigger other actions.

Create the trigger with notify_trigger.sql.

When declaring the trigger, supply the column names you want the JSON payload to contain as arguments to the function (see create_triggers.sql)

The payload returns a JSON object: