I have a question on sql in general - I have a lis...
# help
e
I have a question on sql in general - I have a list of apartments with traits (has parking, allows pets, etc). When a user filters to "has parking", I want to only show the listings where that is true - which is easy. but if they arent filtering to that, i dont only want to show the listings where it's false (I want to show true & false). Do I need a different call for that? Wondering if I'll need a different call for every variation of the filtering
g
You mention SQL, but if you are using the JS library you can either use .match with multiple equal conditions filled in per column. You can also chain only filters with values by building your query up with additional .whateverfilter() added to the query and then execute {} = await query when done. In SQL you would have to build the SQL statement programmatically then use it, but it has been ages since I've done that so can't help.
e
🙏 we're using the API, so thinking .rpc is the best way to pull it
g
You can do rpc. I just build up the query in a js loop of a selected filters array [{column,filtertype,val})] and do query = query.filtertype(column, val) using a switch statement on filtertype. I start query with let query=supabase.from('table'), then execute the finished query with {data,error} = await.query.