I have a query that is checking the jsonb genre column and returning all movies that contain a passed genre number. As so:
SELECT id, name, year, description, "avgRating", "posterPath", genres, "trailerPath", seen
FROM movies
WHERE genres @> $1
ORDER BY year desc
So if I pass '18' as $1 (the $1 is coming from a node module) an example row would be:
On the front end drop down have also included an 'ALL' choice that can be passed. Originally i just had my server detect the 'ALL' value and instead run a query for the entire table. The current implementation is unfortunately causing issues with combining filters for queries now, So my question is whether there is a value I can pass to the @> operator that would return movies with any genre or do I need to change the structure of my query?
--- edit pertaining to passing arrays to the query ---
Testing solution queries in pgAdmin 4 i pass the following:
SELECT id, name, year, description, "avgRating", "posterPath", genres, "trailerPath", seen FROM movies WHERE genres @> [18] ORDER BY year desc
And I get back the following error:
ERROR: syntax error at or near "[" LINE 3: WHERE genres @> [18] ^ SQL state: 42601 Character: 122
The arrow is intended to point at the opening array bracket point out the location of the error

WHERE genres @> coalesce(nullif($1, 'ALL'), genres)should do it