postgrelize / IncrementOptions
Type Alias: IncrementOptions<T> ​
IncrementOptions<
T> =QueryOptionsBase&Readonly<{by?:number;silent?:boolean;where?:WhereOptions<T>; }>
Defined in: src/model/write-options.ts:176
Options of increment and decrement.
Runs one UPDATE ... SET col = col + n and updates updatedAt unless silent.
Type Parameters ​
T ​
T = Values
See ​
Example ​
ts
await Product.increment('stock', { by: 5, where: { id: 1 } });
const opts: IncrementOptions<Product> = { by: 2, silent: true, transaction };
const product = await Product.findByPk(1);
await product!.decrement('stock', opts);