I have a column named order_qty. I want to increase the quantity by some amount. I can not find the suitable update method for this operation.
Equivalent sql query -
update <Table Name> SET order_qty = order_qty +15;
Use gorm.Expr().
db.Model(&Test{ID: 1}).Update("order_qty", gorm.Expr("order_qty + ?", 15))
makes
UPDATE `tests` SET `order_qty` = order_qty + 15 WHERE `tests`.`id` = 1
Thanks
Most helpful comment
Use
gorm.Expr().makes