.filter()
Finds all rows whose column
satisfies the filter.
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.filter('name', 'in', '("Paris","Tokyo")')
Parameters
columnrequired
object
The column to filter on.
operatorrequired
FilterOperator
The operator to filter with.
valuerequired
any
The value to filter with.
Notes
.filter()
expects you to use the raw PostgREST syntax for the filter names and values, so it should only be used as an escape hatch in case other filters don't work..filter('arraycol','cs','{"a","b"}') // Use Postgres array {} for array column and 'cs' for contains.
.filter('rangecol','cs','(1,2]') // Use Postgres range syntax for range column.
.filter('id','in','(6,7)') // Use Postgres list () for in filter.
.filter('id','in',`(${arr})`) // You can insert a javascript array.
Examples
With select()
const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.filter('name', 'in', '("Paris","Tokyo")')
With update()
const { data, error } = await supabase
.from('cities')
.update({ name: 'Mordor' })
.filter('name', 'in', '("Paris","Tokyo")')
With delete()
const { data, error } = await supabase
.from('cities')
.delete()
.filter('name', 'in', '("Paris","Tokyo")')
With rpc()
// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_cities')
.filter('name', 'in', '("Paris","Tokyo")')
Filter embedded resources
const { data, error } = await supabase
.from('cities')
.select('name, countries ( name )')
.filter('countries.name', 'in', '("France","Japan")')