Let's say I have a jsonb column called meta with this value:
{
"foo": {
"bar": "baz"
}
}
When I want to filter by the meta.foo.bar value, I can do this:
select * from tbl where meta->foo->>bar = 'baz';
Now let's say I want to make the foo an array of objects instead:
{
"foo": [
{ "bar": "baz 1" },
{ "bar": "baz 2" }
]
}
How can I filter by the meta.foo.*.bar values? Tried various combinations of this -> syntax without any luck. Only thing that worked was searching by a specific index in the array, but I want to check all the items, not just one.
FWIW I'd also like to support multiple nested arrays. The use case is filtering by JSON properties in an ORM (http://mikro-orm.io/), so it needs to be dynamic.