I want to update the column qty like this
qty = qty + x
My code is like this
db.Stock.update({
qty: Sequelize.col('Stock.qty') + element.qty
}, {
where: {
item_id: element.item_id
}
})
and my model, I have this also
{
hooks: {
beforeUpdate: function (Stock, options) {
console.log("Stock", Stock._previousDataValues.qty);
},
}
}
but this gives me the error
UPDATE `Stocks` SET `qty`='[object Object]10',`updatedAt`='2018-08-11 13:51:18' WHERE `item_id` = 8
I'm new to the sequelize and how can I successfully do this?