Skip to main content
Version: v1

.overlaps()

Finds all rows whose array or range value on the stated column overlaps (has a value in common) with the specified value.

const { data, error } = await supabase
.from('countries')
.select('name, id, main_exports')
.overlaps('main_exports', ['computers', 'minerals'])

Parameters

  • columnrequiredobject

    The column to filter on.

  • valuerequiredstring | array

    The value to filter with.

      Properties
    • objectrequiredobject

      No description provided.

    • stringrequiredobject

      No description provided.

Notes

  • .overlaps() can work on array columns or range columns.

    .overlaps('arraycol',["a","b"]) // You can use a javascript array for an array column
    .overlaps('arraycol','{"a","b"}') // You can use a string with Postgres array {} for array column.
    .overlaps('rangecol','(1,2]') // Use Postgres range syntax for range column.
    .overlaps('rangecol',`(${arr}]`) // You can insert an array into a string.

Examples

With select()

const { data, error } = await supabase
.from('countries')
.select('name, id, main_exports')
.overlaps('main_exports', ['computers', 'minerals'])

With update()

let countries = await supabase
.from('countries')
.update({ name: 'Mordor' })
.overlaps('main_exports', ['computers', 'minerals'])

With delete()

const { data, error } = await supabase
.from('countries')
.delete()
.overlaps('main_exports', ['computers', 'minerals'])

With rpc()

// Only valid if the Postgres function returns a table type.
const { data, error } = await supabase
.rpc('echo_all_countries')
.overlaps('main_exports', ['computers', 'minerals'])