How to filter realtime subscription? #546
-
I am looking for a way to do something like: const mySubscription = supabase
.from('countries')
.eq('country_type', 5) // this does NOT work
.on('*', payload => {
console.log('Change received!', payload)
})
.subscribe() basically, only get updates for a subset of rows in the table. const mySubscription = supabase
.from('countries:country_type=eq.5')
.on('*', handleRecordsChanged)
.subscribe() This seems to work for INSERT and UPDATE, but I don't get anything for DELETE (meaning if I perform these on the table). Is this a bug or by design? If the latter, how can I subscribe to only get updates for the rows I'm interested in? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @laurentS - I thought this was in the docs, but I think it must have been removed. I added a note here: https://supabase.io/docs/client/subscribe#listening-to-deletes By default Supabase not send deleted records. If you want to receive the deleted record you can enable full replication for the table you are listening too: alter table "your_table" replica identity full; |
Beta Was this translation helpful? Give feedback.
Hey @laurentS - I thought this was in the docs, but I think it must have been removed. I added a note here:
https://supabase.io/docs/client/subscribe#listening-to-deletes
By default Supabase not send deleted records. If you want to receive the deleted record you can enable full replication for the table you are listening too: