-
-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!(supabase): disallow multiple stream filter (#644)
- Loading branch information
Showing
4 changed files
with
129 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
packages/supabase/lib/src/supabase_stream_filter_builder.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
part of './supabase_stream_builder.dart'; | ||
|
||
class SupabaseStreamFilterBuilder extends SupabaseStreamBuilder { | ||
SupabaseStreamFilterBuilder({ | ||
required super.queryBuilder, | ||
required super.realtimeTopic, | ||
required super.realtimeClient, | ||
required super.schema, | ||
required super.table, | ||
required super.primaryKey, | ||
}); | ||
|
||
/// Filters the results where [column] equals [value]. | ||
/// | ||
/// Only one filter can be applied to `.stream()`. | ||
/// | ||
/// ```dart | ||
/// supabase.from('users').stream(primaryKey: ['id']).eq('name', 'Supabase'); | ||
/// ``` | ||
SupabaseStreamBuilder eq(String column, Object value) { | ||
_streamFilter = _StreamPostgrestFilter( | ||
type: _FilterType.eq, | ||
column: column, | ||
value: value, | ||
); | ||
return this; | ||
} | ||
|
||
/// Filters the results where [column] does not equal [value]. | ||
/// | ||
/// Only one filter can be applied to `.stream()`. | ||
/// | ||
/// ```dart | ||
/// supabase.from('users').stream(primaryKey: ['id']).neq('name', 'Supabase'); | ||
/// ``` | ||
SupabaseStreamBuilder neq(String column, Object value) { | ||
_streamFilter = _StreamPostgrestFilter( | ||
type: _FilterType.neq, | ||
column: column, | ||
value: value, | ||
); | ||
return this; | ||
} | ||
|
||
/// Filters the results where [column] is less than [value]. | ||
/// | ||
/// Only one filter can be applied to `.stream()`. | ||
/// | ||
/// ```dart | ||
/// supabase.from('users').stream(primaryKey: ['id']).lt('likes', 100); | ||
/// ``` | ||
SupabaseStreamBuilder lt(String column, Object value) { | ||
_streamFilter = _StreamPostgrestFilter( | ||
type: _FilterType.lt, | ||
column: column, | ||
value: value, | ||
); | ||
return this; | ||
} | ||
|
||
/// Filters the results where [column] is less than or equal to [value]. | ||
/// | ||
/// Only one filter can be applied to `.stream()`. | ||
/// | ||
/// ```dart | ||
/// supabase.from('users').stream(primaryKey: ['id']).lte('likes', 100); | ||
/// ``` | ||
SupabaseStreamBuilder lte(String column, Object value) { | ||
_streamFilter = _StreamPostgrestFilter( | ||
type: _FilterType.lte, | ||
column: column, | ||
value: value, | ||
); | ||
return this; | ||
} | ||
|
||
/// Filters the results where [column] is greater than [value]. | ||
/// | ||
/// Only one filter can be applied to `.stream()`. | ||
/// | ||
/// ```dart | ||
/// supabase.from('users').stream(primaryKey: ['id']).gt('likes', '100'); | ||
/// ``` | ||
SupabaseStreamBuilder gt(String column, Object value) { | ||
_streamFilter = _StreamPostgrestFilter( | ||
type: _FilterType.gt, | ||
column: column, | ||
value: value, | ||
); | ||
return this; | ||
} | ||
|
||
/// Filters the results where [column] is greater than or equal to [value]. | ||
/// | ||
/// Only one filter can be applied to `.stream()`. | ||
/// | ||
/// ```dart | ||
/// supabase.from('users').stream(primaryKey: ['id']).gte('likes', 100); | ||
/// ``` | ||
SupabaseStreamBuilder gte(String column, Object value) { | ||
_streamFilter = _StreamPostgrestFilter( | ||
type: _FilterType.gte, | ||
column: column, | ||
value: value, | ||
); | ||
return this; | ||
} | ||
|
||
/// Filters the results where [column] is included in [value]. | ||
/// | ||
/// Only one filter can be applied to `.stream()`. | ||
/// | ||
/// ```dart | ||
/// supabase.from('users').stream(primaryKey: ['id']).inFilter('name', ['Andy', 'Amy', 'Terry']); | ||
/// ``` | ||
SupabaseStreamBuilder inFilter(String column, List<Object> values) { | ||
_streamFilter = _StreamPostgrestFilter( | ||
type: _FilterType.inFilter, | ||
column: column, | ||
value: values, | ||
); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters