Skip to content

pgListenNotify

function pgListenNotify(client, channel?): WatchSubscribe;

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

A WatchSubscribe backed by Postgres LISTEN/NOTIFY. Pair with withWatch for the postgres or drizzle-over-pg adapters. Your migration owns the trigger that pg_notifys channel with the changed key as payload; this only LISTENs. client must be a dedicated pg Client (not a Pool).

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

WatchSubscribe

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