postgresql - Update a particular JSON field using Sequelize in Postgres -
i have "user" table 1 of fields "info" being json structure:
user table has these fields: id, name, info, created
info filed has structure:
info: { email, password, device: { type, token } }
how can use sequelize update token field specific user in postgres?
i know question sequelize.js, don't know it, let me give general answer postgresql (feel free ignore it). first, postgresql not support modifying json values. json columns should used store json data in database , not manipulate json data. if want manipulate json data in database have use jsonb column. jsonb can modified jsonb_set function , || operator. in case, if can run raw sql queries, this:
update "user" set info = jsonb_set(info,'{device,token}','123') id = 31;
Comments
Post a Comment