KleFaCh
KleFaCh

Reputation: 1

Supabase JS missing "DELETE" event

Here is a snippet of my code

const subscription = supabase
            .from(`messages:channel_id=eq.${props.channelId}`)
            .on('INSERT', payload => addMessage(payload.new))
            .on('UPDATE', payload => updateMessage(payload.new))
            .on('DELETE', payload => removeMessage(payload.old))
            .subscribe()

with the messages table having enabled realtime as well as full replication with currently no RLS enabled for testing purposes.

But I only receive UPDATE and INSERT events, if I delete a row in the messages table, nothing happens (I don't receive any event when logging with console.log).

How can I also receive DELETE events?

Upvotes: 0

Views: 496

Answers (1)

john haimez
john haimez

Reputation: 41

If you want to receive "previous" data for updates and deletions, you will need to set REPLICA IDENTITY to FULL, like this: ALTER TABLE your_table REPLICA IDENTITY FULL;

if help everyone ;-)

Upvotes: 3

Related Questions