Skip to content

Filtering by values in a JSONB list with pattern matching operators? #3409

Discussion options

You must be logged in to vote

I don't think that's possible to do directly. This looks like a case for JSON Path, which is not provided by PostgREST out of the box. You need to use a FUNCTION or VIEW to get a filter like this:

select *
from tbl
where metadata @@ '$.tags[*] ? (@ starts with "b=2024" || @ starts with "c=.")';

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by wolfgangwalther
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants