# authorship() function · @imqueue/pg-prisma

Source: https://imqueue.org/api/pg-prisma/latest/pg-prisma.authorship/
Published: 2026-08-01
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/pg-prisma 1.0.1 — generated reference, not hand-written

Build the query extension that stamps who created, updated or deleted a row.

**Signature:**

```typescript
export declare function authorship(input: AuthorshipOptions): (client: any) => import("@prisma/client/extension").PrismaClientExtends<import("@prisma/client/runtime/client").InternalArgs<{}, {}, {}, {}>>;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| input | [AuthorshipOptions](https://imqueue.org/api/pg-prisma/latest/pg-prisma.authorshipoptions/) | The per-model column config and the actor resolver. |


**Returns:**

(client: any) => import("@prisma/client/extension").PrismaClientExtends<import("@prisma/client/runtime/client").InternalArgs<{}, {}, {}, {}>>

A Prisma extension to pass to `client.$extends()`.

## Remarks

Five operations are covered. `create` and `createMany` stamp `createdBy` and `updatedBy` (each element of a `createMany` array individually). `update` and `updateMany` stamp `updatedBy`, plus `deletedBy` when the write is also setting the model's `deletedAt` column — which is what a soft delete rerouted by [softDelete()](https://imqueue.org/api/pg-prisma/latest/pg-prisma.softdelete/) looks like from here. `upsert` stamps its `create` and `update` branches with the matching rule, resolving the actor once for both.

Authorship cannot be spoofed: any caller-supplied value for the three authorship columns is stripped from `data` before the stamp is applied, so this extension is their sole writer. That holds even when there is no actor — with `getActorId` returning null, the caller's values are still removed and nothing is written in their place, so a system write leaves the columns untouched rather than taking whatever the caller passed.

Models absent from `models` pass through completely untouched, authorship columns included.

## Example


```typescript
const client = new PrismaClient().$extends(authorship({
    models: AUTHORSHIP_MODELS,
    getActorId: () => context.get()?.userId ?? null,
}));
```

