Flutter: Fetch data

Perform a SELECT query on the table or view.

Examples

Getting your data

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

Selecting specific columns

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

Query foreign tables

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

Query the same foreign table multiple times

final data = await supabase
  .from('messages')
  .select('*, users!inner(*)')
  .eq('users.username', 'Jane');

Filtering with inner joins

final data = await supabase
  .from('messages')
  .select('*, users!inner(*)')
  .eq('users.username', 'Jane');

Querying with count option

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

final count = res.count;

Querying JSON data

final data = await supabase
  .from('users')
  .select('''
    id, name,
    address->street
  ''')
  .eq('address->postcode', 90210);

Return data as CSV

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

Switching schemas per query

final data = await supabase
  .useSchema('myschema')
  .from('users')
  .select();