How do I do the spread syntax in postgres UPDATE
UPDATE TABLE <table_name> set data={...original, ...<new_data>} where id='<id>'
in postgres
How do I do the spread syntax in postgres UPDATE
UPDATE TABLE <table_name> set data={...original, ...<new_data>} where id='<id>'
in postgres
where {"a": "b"} is the JSON object spreading into the current data
update <table_name> set data = data || '{"a":"b"}' where id='<id>'
when you need to change a nested value use jsonb_set
update <table_name> set data = jsonb_set(data,'{"a","b"}', '{"attr": "value"}', true) where id='<id>'