Open calvinl opened 5 years ago
Hi - is there any update on this? Would be super helpful. I think we're looking for the postgres equivalent of ||
so something like
set config = config || '{."existingKey": "newValue", "newKey": "newValue" }'::jsonb
It would be great to be able to update nested data in a JSONB column without overwriting the values as
_set
would currently do.Ideally, this would work for both arrays and objects, with arrays using the index of the array element as the path to update. There are probably many ways to do this, but here's one idea I've documented below:
For example, given a table called
users
with a JSONB columninfo
which has the following data:Then the following query:
would update the
info
column to be: