Skip to content

postgrelize / SaveOptions

Type Alias: SaveOptions<T> ​

SaveOptions<T> = QueryOptionsBase & object & object

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

Options of create and instance save.

Runs beforeSave / beforeCreate / beforeUpdate hooks (and their after counterparts) unless hooks is false.

Type Parameters ​

T ​

T = any

Type Declaration ​

fields? ​

optional fields?: readonly (0 extends 1 & T ? any : keyof T & string)[]

Attributes to save; others are ignored. Default: all changed attributes. Mutable so hooks can adjust it, as in v6.

hooks? ​

optional hooks?: boolean

Run lifecycle hooks.

Default Value ​

ts
true

overriding? ​

optional overriding?: "system" | "user"

postgrelize extension

OVERRIDING SYSTEM VALUE / OVERRIDING USER VALUE for identity columns. PostgreSQL extension.

returning? ​

optional returning?: boolean

Return all columns after insert/update; PostgreSQL always uses RETURNING, so this is accepted for v6 compatibility.

Default Value ​

ts
true

silent? ​

optional silent?: boolean

Do not update updatedAt.

Default Value ​

ts
false

validate? ​

optional validate?: boolean

Run validations.

Default Value ​

true (false for bulkCreate)

See ​

Model.create

Example ​

ts
const opts: SaveOptions<User> = { fields: ['name', 'email'], validate: true, transaction };
await user.save(opts);

Released under the MIT License.