# Repository.upsert() method · @imqueue/pg-prisma

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

Insert a row, or update the one already holding its key.

**Signature:**

```typescript
upsert<Row = Entity, Input extends object = Record<string, unknown>>(args: {
        input: Input;
        conflictOn?: readonly string[] | undefined;
        select?: Select | undefined;
    }): Promise<Row>;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| args | { input: Input; conflictOn?: readonly string\[\] \| undefined; select?: [Select](https://imqueue.org/api/pg-prisma/latest/pg-prisma.select/) \| undefined; } |  |


**Returns:**

Promise<Row>

## Remarks

The key is the id unless `conflictOn` names another unique — a queue keyed by `(portfolioId, kind, reference)` has no id to upsert on, and reading first and then writing is a race the unique index would lose.

