Supabase issue with using 'and' & 'or' filters for my table

142 Views Asked by At

I have a React table & im trying to fetch data from my table where the employee count ONLY matches ranges between 1-10 OR 21-50.

const { data, error } = await supabase
        .from<SupabaseData>('masterlist1')
        .select('*')
        .order('Lead ID', { ascending: true })
        .range(startIdx, endIdx)
        .or(`employees.gte.1,employees.lte.10`)
        .or(`employees.gte.21,employees.lte.50`)

This is not working, and the table on my front-end is still full of numbers out of these ranges.

I've tried many variants of the string, and other combinations

1

There are 1 best solutions below

0
On

Here is how you can combine and filters with or filters in Supabase. You can find this example here in the docs.

const { data, error } = await supabase
  .from<SupabaseData>('masterlist1')
  .select('*')
  .order('Lead ID', { ascending: true })
  .range(startIdx, endIdx)
  .or('employees.gte.21,employees.lte.50,and(employees.gte.1,employees.lte.10)')