Filters allow you to only return rows that match certain conditions.
Filters can be used on select()
, update()
, and delete()
queries.
If a Database function returns a table response, you can also apply filters.
final data = await supabase
.from('cities')
.select('name, country_id')
.eq('name', 'The Shire'); // Correct
final data = await supabase
.from('cities')
.eq('name', 'The Shire') // Incorrect
.select('name, country_id');
final data = await supabase
.from('cities')
.select('name, country_id')
.gte('population', 1000)
.lt('population', 10000)
final filterByName = null;
final filterPopLow = 1000;
final filterPopHigh = 10000;
var query = supabase
.from('cities')
.select('name, country_id');
if (filterByName != null) \{ query = query.eq('name', filterByName); \}
if (filterPopLow != null) \{ query = query.gte('population', filterPopLow); \}
if (filterPopHigh != null) \{ query = query.lt('population', filterPopHigh); \}
final data = await query;
final data = await supabase
.from('users')
.select()
.eq('address->postcode', 90210);
final data = await supabase
.from('countries')
.select('''
name,
cities!inner (
name
)
''')
.eq('cities.name', 'Bali');