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
This is now released:
const { data, count } = supabase
.from('countries')
.select('*', { count: 'exact' })
(I'm a maintainer)
As a workaround, you could write a standard Postgres stored procedure or function that returns the count then call that via the SB client.
https://supabase.io/docs/client/rpc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With