Skip to content

pgListenNotify

function pgListenNotify(client, channel?): WatchSubscribe;

Defined in: src/storage/watch.ts:115

A WatchSubscribe backed by Postgres LISTEN/NOTIFY. Pair it with withWatch for the postgres or drizzle-over-pg drivers. Your migration owns the trigger that pg_notifys channel with the changed key as payload; this only LISTENs.

The channel is a parameter: products pass the channel they document ("xtandard_webhooks", …). The neutral default is "xtandard_kv".

Parameter Type Default value
client PgNotificationClient undefined
channel? string "xtandard_kv"

WatchSubscribe

import { Client } from "pg";
const listener = new Client({ connectionString: process.env.DATABASE_URL });
await listener.connect();
const storage = withWatch(base, pgListenNotify(listener, "xtandard_webhooks"));