Skip to content

postgrelize / InsertOptions

Type Alias: InsertOptions<T> ​

InsertOptions<T> = QueryOptionsBase & object

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

postgrelize extension

Options of Model.insert. PostgreSQL extension.

Rows are inserted with a single INSERT and no per-row save hooks; only the bulk-create hooks run.

Type Parameters ​

T ​

T = Values

Type Declaration ​

fields? ​

optional fields?: readonly (keyof T & string)[]

Attributes to insert; others are ignored. Default: all given attributes.

hooks? ​

optional hooks?: boolean

Run beforeBulkCreate / afterBulkCreate hooks.

Default Value ​

ts
true

onConflict? ​

optional onConflict?: OnConflictOptions<T>

Advanced ON CONFLICT handling.

overriding? ​

optional overriding?: "system" | "user"

OVERRIDING SYSTEM VALUE / OVERRIDING USER VALUE for identity columns.

returningOld? ​

optional returningOld?: boolean

postgrelize extension

Return the pre-statement row values as instance.oldValues. PostgreSQL extension, needs PostgreSQL 18+.

validate? ​

optional validate?: boolean

Validate rows before inserting.

Default Value ​

ts
false

See ​

Model.insert

Example ​

ts
const opts: InsertOptions<User> = {
  onConflict: { target: ['email'], action: 'nothing' },
  hooks: false,
};
const rows = await User.insert([{ email: 'a@example.com' }], opts);

Released under the MIT License.