select method
Performs horizontal filtering with SELECT.
supabase.from('users').insert().select('id, messages');
supabase.from('users').insert().select('id, messages').count(CountOption.exact);
By appending count the return type is PostgrestResponse. Otherwise it's the data directly without the wrapper.
Implementation
PostgrestTransformBuilder<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 newHeaders = {..._headers};
final url = overrideSearchParams('select', cleanedColumns);
if (newHeaders['Prefer'] != null) {
newHeaders['Prefer'] = '${newHeaders['Prefer']},';
}
newHeaders['Prefer'] = '${newHeaders['Prefer']}return=representation';
return PostgrestTransformBuilder<PostgrestList>(
_copyWithType(
url: url,
headers: newHeaders,
),
);
}