Flutter: Fetch data

Perform a SELECT query on the table or view.

Parameters

Examples

Getting your data

final data = await supabase
  .from('countries')
  .select();

Selecting specific columns

final data = await supabase
  .from('countries')
  .select('''
    name,
    cities (
      name
    )
  ''');

Query referenced tables

final data = await supabase
  .from('products')
  .select('''
    id,
    supplier:supplier_id ( name ),
    purchaser:purchaser_id ( name )
  ''');

Query referenced tables through a join table

final data = await supabase
  .from('users')
  .select('''
    name,
    teams (
      name
    )
  ''');

Query the same referenced table multiple times

final data = await supabase
  .from('messages')
  .select('''
    content,
    from:sender_id(name),
    to:receiver_id(name)
  ''');

Filtering through referenced tables

final data = await supabase
  .from('cities')
  .select('name, countries(*)')
  .eq('countries.name', 'Estonia');

Querying with count option

final res = await supabase
    .from('cities')
    .select('name')
    .count(CountOption.exact);

final data = res.data;
final count = res.count;

Querying JSON data

final data = await supabase
  .from('users')
  .select('''
    id, name,
    address->city
  ''');

Querying referenced table with inner join

final data = await supabase
  .from('cities')
  .select('name, countries!inner(name)')
  .eq('countries.name', 'Indonesia');

Switching schemas per query

final data = await supabase
  .schema('myschema')
  .from('mytable')
  .select();