Files
supabase/apps/reference/_supabase_dart/generated/stream.mdx

68 lines
1.3 KiB
Plaintext

---
id: stream
title: 'stream()'
slug: /stream
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Notifies of data at the queried table.
```dart
supabase
.from('countries')
.stream(['id'])
.execute();
```
## Notes
- `stream()` will emit the initial data as well as any further change on the database as `Stream` of `List<Map<String, dynamic>>` by combining Postgrest and Realtime.
- Takes a list of primary key columns as its argument.
## Examples
### Listening to a specific table
```dart
supabase
.from('countries')
.stream(['id'])
.execute();
```
### Listening to a specific rows within a table
You can listen to individual rows using the format `{table}:{col}=eq.{val}` - where `{col}` is the column name, and `{val}` is the value which you want to match.
This syntax is the as how you can filter data in Realtime
```dart
supabase
.from('countries:id=eq.120')
.stream(['id'])
.execute();
```
### With `order()`
```dart
supabase
.from('countries')
.stream(['id'])
.order('name', ascending: false)
.execute();
```
### With `limit()`
```dart
supabase
.from('countries')
.stream(['id'])
.order('name', ascending: false)
.limit(10)
.execute();
```