Is it possible to incorporate an OR condition in Supabase Realtime using the PostgresChangeFilter?

53 views Asked by At

In Supabase Realtime, I aim to implement a filter that depends on either of two fields. Is it possible to use an OR condition in the PostgresChangeFilter for the following scenarios?

PostgresChangeFilter(
  type: PostgresChangeFilterType.eq,
  column: 'saved_by',
  value: broadcasterId,
)
PostgresChangeFilter(
  type: PostgresChangeFilterType.eq,
  column: 'updated_by',
  value: broadcasterId,
)
1

There are 1 answers

0
dshukertjr On

There is an in filter that you can use.

const channel = supabase
  .channel('changes')
  .on(
    'postgres_changes',
    {
      event: 'INSERT',
      schema: 'public',
      table: 'colors',
      filter: 'name=in.(red, blue, yellow)',
    },
    (payload) => console.log(payload)
  )
  .subscribe()