I have a JSONB column in a postgres database. The json object it holds is structured like this:
{
"kws": {},
"distinct": 0,
"count": 0
}
Some of the records have nonzero/non-null values, of course.
A colleague has inserted quite a few records where he made the key total_count instead of count. Is there a way to change that key with a query rather than retrieving each record and updating the field?
You have to update the current content, using the magic
-and the jsonb function jsonb_insert();The new key will be named
counterand is using the old value for total_count.