How to count results from a query #517
-
Hey guys I'm perhaps missing something simple here but how can I go about counting the results of a query? I can grab a range of documents from a query using Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 14 replies
-
Hey @andregoldstein! There's a PR here that adds this feature. I'll be updating here when we update the client (should be sometime soon). |
Beta Was this translation helpful? Give feedback.
-
Hummm I think I might be missing something. I just want the count of a query: This works, but I don't think it's efficient?
Seem like this is the recommended solution, but doesn't work for me (returns null):
Any nudges appreciated! |
Beta Was this translation helpful? Give feedback.
-
The const { count, error } = await supabase
.from("properties")
.select("*", { count: "exact", head: true })
if (error) throw error;
console.log(count) // 745
return count; |
Beta Was this translation helpful? Give feedback.
-
How can you do this via an API call instead of using the supabase libary? |
Beta Was this translation helpful? Give feedback.
-
This doesn't seem to be available when selecting from a rpc results, i.e.
The typing system complains that 'count' does not exist, and the count returned is in fact always null. |
Beta Was this translation helpful? Give feedback.
-
rpc count always return null. Some idea?, no problem with data array but count always null. |
Beta Was this translation helpful? Give feedback.
Hey @andregoldstein! There's a PR here that adds this feature. I'll be updating here when we update the client (should be sometime soon).