single()
Return data
as a single object instead of an array of objects.
Query result must be one row (e.g. using .limit(1)
), otherwise this
returns an error.
1const { data, error } = await supabase
2 .from('countries')
3 .select('name')
4 .limit(1)
5 .single()
Examples#
With select()
#
1create table
2 countries (id int8 primary key, name text);
3
4insert into
5 countries (id, name)
6values
7 (1, 'Afghanistan'),
8 (2, 'Albania'),
9 (3, 'Algeria');