Skip to main content
Version: v2 RC

filter()

Match only rows which satisfy the filter. This is an escape hatch - you should use the specific filter methods wherever possible.

Unlike most filters, opearator and value are used as-is and need to follow PostgREST syntax. You also need to make sure they are properly sanitized.

const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.filter('name', 'in', '("Paris","Tokyo")')

Parameters

  • columnrequiredColumnName

    The column to filter on

  • operatorrequiredFilterOperator | not.eq | not.neq | not.gt | not.gte | not.lt | not.lte | not.like | not.ilike | not.is | not.in | not.cs | not.cd | not.sl | not.sr | not.nxl | not.nxr | not.adj | not.ov | not.fts | not.plfts | not.phfts | not.wfts

    The operator to filter with, following PostgREST syntax

      Properties
    • not.wftsrequiredliteral

      No description provided.

    • not.phftsrequiredliteral

      No description provided.

    • not.plftsrequiredliteral

      No description provided.

    • not.ftsrequiredliteral

      No description provided.

    • not.ovrequiredliteral

      No description provided.

    • not.adjrequiredliteral

      No description provided.

    • not.nxrrequiredliteral

      No description provided.

    • not.nxlrequiredliteral

      No description provided.

    • not.srrequiredliteral

      No description provided.

    • not.slrequiredliteral

      No description provided.

    • not.cdrequiredliteral

      No description provided.

    • not.csrequiredliteral

      No description provided.

    • not.inrequiredliteral

      No description provided.

    • not.isrequiredliteral

      No description provided.

    • not.ilikerequiredliteral

      No description provided.

    • not.likerequiredliteral

      No description provided.

    • not.lterequiredliteral

      No description provided.

    • not.ltrequiredliteral

      No description provided.

    • not.gterequiredliteral

      No description provided.

    • not.gtrequiredliteral

      No description provided.

    • not.neqrequiredliteral

      No description provided.

    • not.eqrequiredliteral

      No description provided.

    • FilterOperatorrequiredobject

      No description provided.

  • valuerequiredunknown

    The value to filter with, following PostgREST syntax

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")')