how to update the age and the status at once,
I have a jsonb field type, I need to update 2 properties (age and status).
I am able to update only either age and status, using the command below, how to do update both 'age' and 'status' at once?
**Update test Set attributes = jsonb_set(attributes, array['age'],to_jsonb(32))**
Best Answer
The
jsonb_set
function accepts ajsonb
value as its first argument and returns anotherjsonb
value, which is the result of the modification applied. You can pass the resultingjsonb
value to anotherjsonb_set
call where you would apply the second change. This would result in nestedjsonb_set
calls, as a_horse_with_no_name suggested in the comments. The statement would look something like this: