I have a JSON field like this. {Price:0,Title:'Test'}
. I want to update Price value with 10 on MYSQL with sequelize.
I am using MYSQL 8 and JSON field supported. But in sequelize want to change Only Price with sequelize directly write to the field with {Price:10} and another fields are deleting. How can I solve this?
(async () => {
await e_products_v2.update(
{
Preferences: {
Price: 0,
},
},
{ where: { id: 1 } }
);
})();
Wang Liang :
let p = await db.e_products_v2.findOne({ where: { id: 20 } })\n \np.Preferences = { ...p.Preferences, Price: 10 }\nawait p.update({ Preferences: p.Preferences })\n",
2021-03-06T18:45:11