I want to retrieve row count in Supabase.
I am guessing it would be something like this:
const { data, error } = await supabase
.from('cities')
.select('name', 'COUNT(*)')
Is this possible with Supabase?
For future visitors, we are working on this functionality with the PostgREST maintainer:
https://github.com/supabase/postgrest-js/issues/94
(I'm a maintainer)
This is now released:
const { data, count } = supabase
.from('countries')
.select('*', { count: 'exact', head: true })
If you want to return the results simultaneously, remove head
:
const { data, count } = supabase
.from('countries')
.select('*', { count: 'exact' })