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 extensionAdvanced 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') } },
},
},
});