I have jsonb column feeds with data in the form of this:
[{
"id": 99999999,
"lang": "pt",
"entities": {
"urls": [],
"media": [{
"id": 123456456,
"type": "photo",
"id_str": "123456456",
"indices": [37, 59],
}]
},
"favorited": false,
"retweeted": false,
"truncated": false
}]
How do I query the first media ->> id since it's in an json array? So that the result is like this:
id media_id
---------------------------
99999999 123456456
I tried jsonb_array_elements but can't seem to get the output I want, especially the part where the media is nested within another array.