Hi everyone,
I created a function on my Supabase backend to fetch user items from different tables, which I then used as a REST API call on WeWeb. However, when I insert a new item, the change doesn’t reflect in my WeWeb collection in real-time. The new item only shows up if I manually trigger a “Refetch Collection” action.
Although refetching works, it defeats the purpose of using real-time updates. My aim is to have the collection update automatically whenever a new item is inserted. Does anyone have suggestions to fix this?
The pure Supabase Realtime - Listen to Postgres Changes works only on tables, so your collections need to:
Be fetching just a single table - no JOINs
Be a table - no Function, no View, no Edge Function
For anything else, you need to use the Subscribe to a channel function to subscribe to Postgres Changes and handle it all yourself. Or use the new Broadcasts from the Database feature, but @Micah told me it takes way too much effort to set up - now it is doable though, WeWeb should support it.
I switched to REST since Postgres functions can’t handle data like a collection, so I had to either change it to REST or transform the result into a variable, which definitely won’t be real-time. I get that it’s a lost cause. Maybe using a webhook to the backend could help, updating whenever there are new or modified items, but yeah, it does sound like a real pain.
Hi,
In your workflow, whether it’s “on click” or “on change” depending on your setup, try adding a “fetch collection” action by selecting your Supabase table. That should refresh the display in real time.
Each time, I will need to refetch all the items, which is highly inefficient if I have a lot of items.
If two users are working on the same data, one can edit and refresh the data upon completion, but the other user won’t see the updates until they manually reload or refetch the data, which could leave them with outdated information for an extended period.