select method

PostgrestFilterBuilder<PostgrestList> select([
  1. String columns = '*'
])

Perform a SELECT query on the table or view.

supabase.from('users').select('id, messages');
supabase.from('users').select('id, messages').count(CountOption.exact);

By appending count the return type is PostgrestResponse. Otherwise it's the data directly without the wrapper.

Implementation

PostgrestFilterBuilder<PostgrestList> select([String columns = '*']) {
  // Remove whitespaces except when quoted
  var quoted = false;
  final re = RegExp(r'\s');
  final cleanedColumns = columns.split('').map((c) {
    if (re.hasMatch(c) && !quoted) {
      return '';
    }
    if (c == '"') {
      quoted = !quoted;
    }
    return c;
  }).join();

  final url = overrideSearchParams('select', cleanedColumns);
  return PostgrestFilterBuilder(_copyWithType(
    url: url,
    method: METHOD_GET,
  ));
}