I have jsonb datatype column "payload" in postgres table which has the value as below:
{"testEvents": [
{
"id": 113068,
"name1": "test",
"count": 15
},
{
"id": 113069,
"name1": "test1",
"count": 15
}
]
}
Now I want to update the inner jsonarray by adding one more jsonobject to it. So, my results will be like
{"testEvents": [
{
"id": 113068,
"name1": "test",
"count": 15
},
{
"id": 113069,
"name1": "test1",
"count": 15
}
,
{
"id": 113070,
"name1": "test2",
"count": 18
}
]
}
I tried the below query:
UPDATE table SET payload = payload ||'{"id":113070,"name1":"test2","count":18}';
But it is replacing the previous value. Since am new to this topic, can anyone please help with the right way to do it.