Skip to content

postgrelize / UpdateOptions

Type Alias: UpdateOptions<T> ​

UpdateOptions<T> = QueryOptionsBase & object & object & BulkHookOptions

Defined in: src/model/bulk-options.ts:92

Options of static update.

Extends BulkHookOptions. Updates updatedAt unless silent.

Type Parameters ​

T ​

T = Values

Type Declaration ​

fields? ​

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

Attributes to update; others are ignored. Mutable so hooks can adjust it, as in v6.

from? ​

optional from?: JoinSources

postgrelize extension

Extra relations (UPDATE ... FROM), keyed by alias; reference them with col('alias.attr'). PostgreSQL extension.

paranoid? ​

optional paranoid?: boolean

For paranoid models: false also updates soft-deleted rows.

Default Value ​

ts
true

returning? ​

optional returning?: boolean

Return updated rows as the second element of the result.

returningOld? ​

optional returningOld?: boolean

postgrelize extension

With returning: expose values before the update as instance.oldValues. PostgreSQL extension, needs PostgreSQL 18+.

silent? ​

optional silent?: boolean

Do not update updatedAt.

Default Value ​

ts
false

validate? ​

optional validate?: boolean

Validate the new values.

Default Value ​

ts
true

where ​

where: WhereOptions<T>

Rows to update.

See ​

Model.update

Example ​

ts
const [count] = await User.update(
  { active: false },
  { where: { lastLogin: { [Op.lt]: new Date('2020-01-01') } }, transaction },
);
const opts: UpdateOptions<Task> = { where: { done: false }, returning: true };

Released under the MIT License.