Home:ALL Converter>Update a JSON column in mysql using sequelize

Update a JSON column in mysql using sequelize

Ask Time:2018-03-26T19:25:46         Author:arvind

Json Formatter

I am using sequelize with mysql and i am trying to update a column which is of JSON type. I specifically want to update a particular key in the JSON. Here is what I have tried till now.

Profile.update(
        values,
      {
        where: {
          id : id
       }
    }).then(function(obj) {
       ...
    }.catch(function(err){
       ...
    })

It removes the entire value and updates the new value. I want to just update that particular key alone. The content of values is,

{
    "details"{ 
        name : "user"
    }
}

details is the field i want to update and name is the key to update. I couldn't find any helpful resource for this with sequelize. Thanks in advance.

Author:arvind,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/49490322/update-a-json-column-in-mysql-using-sequelize
yy