I have the following postgresql rows as JSONB row:
{age:26}
And I would like to replace it so that that i looks like this:
{age: 30, city: "new york city"}
How can I do this in postgressql? Someone metioned using jsonb_set()
, but I haven't seen any examples of updating multiple keys in one query.
Use jsonb_set() inside jsonb_set()
jsonb_set(jsonb_set('{age:26}'::jsonb,'{age}','"30"'::jsonb)::jsonb,'{city}','"new york city"'::jsonb)