Data Realtime

Let's explore how to use Realtime's Postgres Changes feature to listen to database events.

The Plugin Listens to all Database related Changes when the feature has been enabled. This includes when (based on your setup) a row have been Inserted/Updated/Deleted.

First Let's head over to Supabase, and verify that we have Realtime enabled:

As you see in the Example "Authorized Subscribers". This is very important, as you need to have access to data in the first place to subscribe to the changes.

In other words: You'd need to be able to fetch the data to be able to listen to the changed via Realtime.

Let look at an example:

This is a Data element which was setup to return Posts based on Category. So here we have the table "post" (not visible in the screenshot). Let's return all the fields we need with some explanation (We also detail some of this here)

*,category_unique_id!inner(name,id,unique_id)

As you can see it's a bit more complex now. Let's break it down:

  • The first asterisk "*" means we'd like to return all fields in that table.

  • The comma separates each section, when we define other things, in this case we'd like to return data from a foreign table which is referenced inside "post"

  • We'd added the name of the column which is the foreign table called "category_unique_id"

  • Let's add "!inner" This is important when we'd like to make sure we can use the referenced fields for filtering

  • In a round bracket we add the names of the columns we'd like to return from the referenced foreign table. in this case "name,id,unique_id". We can add an asterisk to return all fields. If the referenced foreign table also have another table inside we can continue with the same login inside the first round bracket. Again check out the detailed post here.

In the screenshot you might've seen the Realtime Filter's name is "category_unique_id.id", which can be confusing at first. But essentially What happens here, is that I'm selecting the ID field of the returned Foreign Table and the value is coming from another Supabase element which have been setup to show the categories. Like so:

Last updated