Reputation: 23
{
"L1": [
{
"f1": "446",
"f2": true,
"f3": true
},
{
"f1": "191",
"f2": true,
"f3": true
}
]
}
I want to filter where f2 is true and f3 is true in PostgreSQL.
Upvotes: 1
Views: 189
Reputation:
You can use a JSON path query to get all elements where both keys are true and then compare that to the total length of the array:
select ...
from the_table
where jsonb_array_length(the_column -> 'L1') = jsonb_array_length(jsonb_path_query_array(the_column, '$.L1[*] ? (@.f2 == true && @.f3 == true)'))
Upvotes: 1