I've searched around but this seems to be a more unique requirement for querying JSONB fields than is common and haven't found a solution yet. My table has a jsonb field called 'plan', the content of which looks like this:
{
days: [
{
summary: {
total: 100
}
}
]
}
There could be potentially infinity day objects inside the days array. Is it possible to run a query that selects all rows where 'total' is greater than or less than a given number in at least one of the day objects?
If necessary I can rearrange the table or take the 'summary' data and put it in a postgres array field.