Skip to content

postgrelize / UpsertOptions

Type Alias: UpsertOptions<T> ​

UpsertOptions<T> = SaveOptions<T> & object

Defined in: src/model/write-options.ts:85

Options of upsert.

Extends SaveOptions. With onConflict the result of upsert becomes [instance, created].

Type Parameters ​

T ​

T = Values

Type Declaration ​

conflictFields? ​

optional conflictFields?: readonly string[]

Conflict target columns. Default: unique key containing a given attribute, else the primary key.

onConflict? ​

optional onConflict?: OnConflictOptions<T>

postgrelize extension

Advanced ON CONFLICT handling; the result becomes [instance, created]. PostgreSQL extension.

overriding? ​

optional overriding?: "system" | "user"

postgrelize extension

OVERRIDING SYSTEM VALUE / OVERRIDING USER VALUE for identity columns.

See ​

Model.upsert

Example ​

ts
const [user] = await User.upsert(
  { email: 'a@example.com', name: 'Ann' },
  { conflictFields: ['email'] },
);

Released under the MIT License.