Supabase Realtime Postgres Changes doesn't trigger on "lost" data
I have a table named
rides
that contain a column named pro_id
which is a foreign key but not really relevant.
When using Supabase channel on postgres_changes
with a filter on pro_id
like so :
It doesn't trigger when the pro_id
of a row is changing to an other id
Basically a row that was "linked" to a user now is owned by an other user.
I understand that the problem is the filter that react only on changes on row that match the filter. But how do you do to react on change that impact directly the filter ?
Thank you for your help.2 Replies
There is a not equal filter, but that would fire for all changes not your id which is also what you don't want. I don't know of a way with postgres_changes.
You might look at the new broadcast from database realtime feature. It is recommended to replace postgres_changes. With it could could subscribe to channel pro_id and then have the update trigger function detect NEW or OLD and send a message to both. It is complicated though.
Yea I looked into it but overthinked it a bit. I could just subscribe to something like
broadcast_${pro_id}
and send messages from Edge Functions or functions triggered on row update.
Thank you tho, you sent me on the right path.