stamp() function

Build the middleware that stamps authorship and turns deletes into stamps.

Signature:

export declare function stamp(input: StampOptions): SqlMiddleware;

Parameters

Parameter

Type

Description

input

StampOptions

Per-table columns and the actor resolver.

Returns:

SqlMiddleware

Middleware for the middleware array of the postgres() factory.

Remarks

One middleware rather than two because the two halves are inseparable: a soft delete only exists as an update **because** this rewrote the delete into one, and only this knows that the update it is stamping is a deletion. Split across two middlewares — as the Prisma 7 extensions were — the second has to infer the deletion from the assignments, and the pair has to be ordered correctly by every caller, with deletedBy silently never written when it is not. Neither hazard can be expressed here.

Reads are filtered across the **whole statement**, not just its outermost from, so a soft-deleted row reached through a relation is excluded too.

A null actor stamps null rather than skipping the column, which is what makes a system write distinguishable from one whose author was never recorded.

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.