© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
2 replies
garyditsch

Getting total count of records when on a view with single day

I using supabase (with Remix) for the first time to build a personal project, for tracking daily behaviors. It's pretty simple, and here is my supabase client and call for getting the daily information:

const { supabase } = await createSupabaseServerClient({request})
const { data, error } = await supabase
.from('behaviors')
.select(

      id, goal_id, created_at, user_id,
      goals (
        id, goal, value
      )
    

      id, goal_id, created_at, user_id,
      goals (
        id, goal, value
      )
    
)
.gte('created_at', stringDate)
.lt('created_at', nextDayString)

return {
data: data,
error: error
}

Success, as now I have a list of my completed behaviors for that day and the primary goal's information. But now I want to get a count for how many times each behavior has been completed this year (row count from behavior table for each behavior completed that day).

What would be best practice? The easiest solution for me would be to change this query to pull in all behaviors and on the client parse the return, but that feels like over fetching and not ideal.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Total count from range
SupabaseSSupabase / help-and-questions
13mo ago
Total number of rooms
SupabaseSSupabase / help-and-questions
4y ago
Order by view count in JS library
SupabaseSSupabase / help-and-questions
4y ago
Getting a 500 error when deploying on vercel?
SupabaseSSupabase / help-and-questions
4y ago