Return real-time data from your table as a Flow.
selectAsFlow
and selectSingleValueAsFlow
will emit the initial data and then listen for changes.filter
parameter to filter the data and a primaryKey
parameter to cache the data by the primary key.Realtime
and Postgrest
plugins to be installed.T
must be a serializable class.Realtime
plugin directly.The primary key to cache the data by. Can be a property reference or a custom primary key.
The name of the channel to use for the realtime updates. If null, a channel name following the format "schema:table:id" will be used
The filter to apply to the data.
val flow: Flow<List<Country>> = supabase.from("countries").selectAsFlow(Country::id)
flow.collect \{
for (country in it) \{
println(country.name)
\}
\}
val flow: Flow<List<Country>> = supabase.from("countries").selectAsFlow(
Country::id,
filter = FilterOperation("name", FilterOperator.ILIKE, "a%")
)
flow.collect \{
for (country in it) \{
println(country.name)
\}
\}
val flow: Flow<Country> = supabase.from("countries").selectSingleValueAsFlow(Country::id) \{
//You can use the same filter methods as in the `select` method, but the result is limited to a single row
Country::id eq 1
//or
eq("id", 1)
\}
flow.collect \{
println("My country is $it")
\}