Interface UpsertOptions<TAttributes>

Options for Model.upsert method

interface UpsertOptions<TAttributes> {
    [COMPLETES_TRANSACTION]?: boolean;
    benchmark?: boolean;
    conflictFields?: (keyof TAttributes)[];
    conflictWhere?: WhereOptions<TAttributes>;
    connection?: null | AbstractConnection;
    fields?: (keyof TAttributes)[];
    hooks?: boolean;
    logging?: false | ((sql, timing?) => void);
    returning?: boolean | (Col | Literal | keyof TAttributes)[];
    searchPath?: string;
    transaction?: null | Transaction;
    validate?: boolean;
}

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).

conflictFields?: (keyof TAttributes)[]

Optional override for the conflict fields in the ON CONFLICT part of the query. Only supported in Postgres >= 9.5 and SQLite >= 3.24.0

conflictWhere?: WhereOptions<TAttributes>

An optional parameter that specifies a where clause for the ON CONFLICT part of the query (in particular: for applying to partial unique indexes). Only supported in Postgres >= 9.5 and SQLite >= 3.24.0

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)[]

The fields to insert / update. Defaults to all fields.

If none of the specified fields are present on the provided values object, an insert will still be attempted, but duplicate key conflicts will be ignored.

hooks?: boolean

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

Default

true
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

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

Fetch back the affected rows (only for postgres)

searchPath?: string

An optional parameter to specify the schema search_path (Postgres only)

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

Run validations before the row is inserted

Default

true