I need to update a jsonb object in PostgreSQL but am unable to identify the correct syntax for updating the same, below are the use cases for the same.
Data in table
Create table jsondata (id int, data jsonb);
INSERT INTO jsondata VALUES
(1,'[{"cc": null, "subsectionid": 26}, {"cc": null, "subsectionid": 27}]');
SELECT * from jsondata;
Use case:
Want to update the value of cc where subsectionid =27
Query tried:
UPDATE jsondata
SET data = data || '{null: ["Lake Providence"]}'::jsonb
WHERE data->>'subsectionid' = '27'
Please help me to achieve this.