postgresqlreal-timesupabasesupabase-databasesupabase-js

How to listen to supabase realtime changes when a column parent is null?


I am trying to listen to supabase realtime changes when parentTodos is null. How can I do that?

const { createClient } = require('@supabase/supabase-js')

const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_KEY, {})

// Set your custom JWT here
supabase.realtime.setAuth('your-custom-jwt')

const channel = supabase
  .channel('db-changes')
  .on(
    'postgres_changes',
    {
      event: '*',
      schema: 'public',
      table: 'todos',
      filter: 'parent IS NULL',
    },
    (payload) => console.log(payload)
  )
  .subscribe()

This is not working whereas, removing the filter listens to all changes in the todos table.


Solution

  • is filter is currently not supported on Supabase realtime, so if you want to do this, you would have to listen to all changes, and just filter out the ones that have values on parentTodos column on the client side.