Combine multiple filters with logical/boolean operation #18535
-
Is it possible to combine multiple front-end (js) filters? For example I have columns age_from and age_to, which can be NULL. I know I can combine the two like this:
but that leads to two separate filters (filtering all rows with NULL, not just the ones with lower age). I need them joined into a single filter.
I imagine it would be useful for many other things. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Several ways. You can use .or() with various logic combos in it and if you don't separate them with a comma then it will run as one big logic statement. You can also do conditional filtering which is probably an easier way. With that method you just chain the filters based on their value being present to the query and then await the query to execute it. https://supabase.com/docs/reference/javascript/using-filters?example=conditional-chaining |
Beta Was this translation helpful? Give feedback.
-
Hi im trying to do something similar but apparently im doing something wrong. I have a select query where I retrieve my data and some fields are using other tables. I tried two approaches
The first one is working half way. The .not is working and removes all my bikes with null ids. What happens next if my values = 'A' then my bikes_types with names B become null. The second approach is not working at all I'm getting the following error
|
Beta Was this translation helpful? Give feedback.
Several ways. You can use .or() with various logic combos in it and if you don't separate them with a comma then it will run as one big logic statement.
You can also do conditional filtering which is probably an easier way. With that method you just chain the filters based on their value being present to the query and then await the query to execute it.
https://supabase.com/docs/reference/javascript/using-filters?example=conditional-chaining