Skip to main content
Version: v2 RC

contains()

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

const { data, error } = await supabase
.from('users')
.select()
.contains('name', ['is:online', 'faction:red'])

Parameters

  • columnrequiredColumnName

    The jsonb, array, or range column to filter on

  • valuerequiredstring | Record | array

    The jsonb, array, or range value to filter with

      Properties
    • objectrequiredobject

      No description provided.

    • stringrequiredobject

      No description provided.

    • Recordrequiredobject

      No description provided.

Examples

On array columns

const { data, error } = await supabase
.from('issues')
.select('title')
.contains('tags', ['is:open', 'severity:high'])

On range columns

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

const { data, error } = await supabase
.from('reservations')
.select()
.contains('during', '[2000-01-01 13:00, 2000-01-01 13:30)')

On jsonb columns

const { data, error } = await supabase
.from('users')
.select('name')
.contains('address', { postcode: 90210 })