maybeSingle method
Retrieves at most one row from the result.
Result must be at most one row or nullable
(e.g. using eq
on a UNIQUE column or limit(1)
),
otherwise this will result in an error.
Implementation
PostgrestTransformBuilder<PostgrestMap?> maybeSingle() {
// Temporary fix for https://github.com/supabase/supabase-flutter/issues/560
// Issue persists e.g. for `.insert([...]).select().maybeSingle()`
final newHeaders = {..._headers};
if (_method?.toUpperCase() == 'GET') {
newHeaders['Accept'] = 'application/json';
} else {
newHeaders['Accept'] = 'application/vnd.pgrst.object+json';
}
return PostgrestTransformBuilder(
_copyWithType(
maybeSingle: true,
headers: newHeaders,
),
);
}