withoutChangeNotify() function
Run fn in a transaction whose row changes notify nobody.
Signature:
export declare function withoutChangeNotify<T>(client: RawClient, fn: (tx: RawExecutor) => Promise<T>, setting?: string): Promise<T>;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
client |
A client that can open a transaction. | |
|
fn |
(tx: RawExecutor) => Promise<T> |
Work to run with notifications suppressed. |
|
setting |
string |
(Optional) Setting the trigger reads (default CHANGE_NOTIFY_SUPPRESS_SETTING). |
Returns:
Promise<T>
Whatever fn resolves to.
Remarks
For a bulk write — an import, a backfill, a reconciliation — where the trigger would otherwise emit one notification per row. Forty thousand rows is forty thousand payloads through a single Postgres notification queue, to tell listeners something they would rather hear once.
The suppression is SET LOCAL, so it belongs to this transaction alone: it reverts on commit or rollback, and no concurrent session is affected. It is a setting the trigger itself reads, **not** session_replication_role — that would silence foreign-key enforcement too, and a bulk load run under it can commit orphan rows.
Do the writes on the tx handed to fn. Writes issued on the outer client go out on a different connection, where the setting was never applied, and will notify as usual.
Nothing is emitted afterwards to say what changed — a caller that suppresses is telling listeners it will account for the change itself, by bumping a revision, invalidating a tag, or announcing the import once when it is done.
Example
await withoutChangeNotify(pool, async tx => {
await tx.query(bulkUpsert);
});
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.