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.

1const { data, error } = await supabase
2  .from('countries')
3  .select()
4  .filter('name', 'in', '("Algeria","Japan")')

Parameters#

  • columnrequired
    ColumnName

    The column to filter on

  • operatorrequired
    FilterOperator
    |
    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
    • FilterOperatorrequired
      object

      No description provided.

  • valuerequired
    unknown

    The value to filter with, following PostgREST syntax

Notes#

filter() expects you to use the raw PostgREST syntax for the filter values.

1.filter('id', 'in', '(5,6,7)')  // Use `()` for `in` filter
2.filter('arraycol', 'cs', '{"a","b"}')  // Use `cs` for `contains()`, `{}` for array values

Examples#

With select()#

1create table
2  countries (id int8 primary key, name text);
3
4insert into
5  countries (id, name)
6values
7  (1, 'Afghanistan'),
8  (2, 'Albania'),
9  (3, 'Algeria');

On a foreign table#

1create table
2  countries (id int8 primary key, name text);
3create table
4  cities (
5    id int8 primary key,
6    country_id int8 not null references countries,
7    name text
8  );
9
10insert into
11  countries (id, name)
12values
13  (1, 'Germany'),
14  (2, 'Indonesia');
15insert into
16  cities (id, country_id, name)
17values
18  (1, 2, 'Bali'),
19  (2, 1, 'Munich');