containedBy()

Only relevant for jsonb, array, and range columns. Match only rows where every element appearing in column is contained by value.

1const { data, error } = await supabase
2  .from('classes')
3  .select('name')
4  .containedBy('days', ['monday', 'tuesday', 'wednesday', 'friday'])

Parameters#

  • columnrequired
    ColumnName

    The jsonb, array, or range column to filter on

  • valuerequired
    string
    |
    Record
    |
    array

    The jsonb, array, or range value to filter with

      Properties
    • object
      required
      object

      No description provided.

    • stringrequired
      object

      No description provided.

    • Recordrequired
      object

      No description provided.

Examples#

On array columns#

1create table
2  classes (
3    id int8 primary key,
4    name text,
5    days text[]
6  );
7
8insert into
9  classes (id, name, days)
10values
11  (1, 'Chemistry', array['monday', 'friday']),
12  (2, 'History', array['monday', 'wednesday', 'thursday']);

On range columns#

Postgres supports a number of range types. You can filter on range columns using the string representation of range values.

1create table
2  reservations (
3    id int8 primary key,
4    room_name text,
5    during tsrange
6  );
7
8insert into
9  reservations (id, room_name, during)
10values
11  (1, 'Emerald', '[2000-01-01 13:00, 2000-01-01 15:00)'),
12  (2, 'Topaz', '[2000-01-02 09:00, 2000-01-02 10:00)');

On jsonb columns#

1create table
2  users (
3    id int8 primary key,
4    name text,
5    address jsonb
6  );
7
8insert into
9  users (id, name, address)
10values
11  (1, 'Michael', '{ "postcode": 90210, "street": "Melrose Place" }'),
12  (2, 'Jane', '{}');