I have the below data in a JSONB column in PostgreSQL.
{
"myFirstDeck" : {
"cards": [1, 2, 3]
}
}
I would like to use one of the inbuilt JSONB PostgreSQL functions to push/append an integer to the cards array inside of the myFirstDeck key/object.
Any assistance would be much appreciated.
I have tried various variations using jsonb_set and concatenation but am struggling to get it working.
SELECT jsonb_set('{"myFirstDeck" : {"cards": [1, 2, 3]}}' :: jsonb, '{myFirstDeck,cards}' :: text[], to_jsonb('new_jsonb' :: text)). Result :{"myFirstDeck": {"cards": "new_jsonb"}}. see the manual