Skip to content

postgrelize / OnConflictOptions

Type Alias: OnConflictOptions<T> ​

OnConflictOptions<T> = Readonly<{ action: "nothing" | OnConflictUpdateAction<T>; target?: OnConflictTarget<T>; }>

Defined in: src/model/on-conflict-builder.ts:66

postgrelize extension

Advanced INSERT ... ON CONFLICT specification. PostgreSQL extension.

Type Parameters ​

T ​

T

Example ​

ts
const rows = [{ tenantId: 1, key: 'views', hits: 1, version: 2 }];
await Product.bulkCreate(rows, {
  onConflict: {
    target: ['tenantId', 'key'],
    action: {
      update: { hits: literal('"Product"."hits" + EXCLUDED."hits"'), updatedAt: fn('now') },
      where: { version: { [Op.lt]: excluded('version') } },
    },
  },
});

Released under the MIT License.