Interface UpdateOptions<TAttributes>

Options used for Model.update

interface UpdateOptions<TAttributes> {
    [COMPLETES_TRANSACTION]?: boolean;
    benchmark?: boolean;
    connection?: null | AbstractConnection;
    fields?: (keyof TAttributes)[];
    hooks?: boolean;
    individualHooks?: boolean;
    limit?: number | Nullish | Literal;
    logging?: false | ((sql, timing?) => void);
    paranoid?: boolean;
    returning?: boolean | (Col | Literal | keyof TAttributes)[];
    sideEffects?: boolean;
    silent?: boolean;
    transaction?: null | Transaction;
    validate?: boolean;
    where: WhereOptions<TAttributes>;
}

Type Parameters

  • TAttributes = any

Hierarchy (view full)

Properties

[COMPLETES_TRANSACTION]?: boolean

Indicates if the query completes the transaction Internal only

benchmark?: boolean

Pass query execution time in milliseconds as second argument to logging function (options.logging).

connection?: null | AbstractConnection

The connection on which this query must be run. Mutually exclusive with Transactionable.transaction.

Can be used to ensure that a query is run on the same connection as a previous query, which is useful when configuring session options.

Specifying this option takes precedence over CLS Transactions. If a transaction is running in the current AsyncLocalStorage context, it will be ignored in favor of the specified connection.

fields?: (keyof TAttributes)[]

Fields to update (defaults to all fields)

hooks?: boolean

If false the applicable hooks will not be called. The default value depends on the context.

Default

true
individualHooks?: boolean

Run before / after update hooks?. If true, this will execute a SELECT followed by individual UPDATEs. A select is needed, because the row data needs to be passed to the hooks

Default

false
limit?: number | Nullish | Literal

How many rows to update

Only for mysql and mariadb, Implemented as TOP(n) for MSSQL; for sqlite it is supported only when rowid is present

logging?: false | ((sql, timing?) => void)

A function that gets executed while running the query to log the sql.

Type declaration

    • (sql, timing?): void
    • Parameters

      • sql: string
      • Optional timing: number

      Returns void

paranoid?: boolean

If true, only non-deleted records will be returned. If false, both deleted and non-deleted records will be returned.

Only applies if InitOptions.paranoid is true for the model.

Default

true
returning?: boolean | (Col | Literal | keyof TAttributes)[]

Return the affected rows (only for postgres)

Default

false
sideEffects?: boolean

Whether to update the side effects of any virtual setters.

Default

true
silent?: boolean

If true, the updatedAt timestamp will not be updated.

transaction?: null | Transaction

The transaction in which this query must be run. Mutually exclusive with Transactionable.connection.

If the Sequelize disableClsTransactions option has not been set to true, and a transaction is running in the current AsyncLocalStorage context, that transaction will be used, unless null or another Transaction is manually specified here.

validate?: boolean

Should each row be subject to validation before it is inserted. The whole insert will fail if one row fails validation.

Default

true

Options to describe the scope of the search.