'How can I fetch feedback with total upvotes from supabase and also check if user has upvoted or not?

So I am creating an app in React with Supabase as backend. I am stuck on upvote functionality for the feedback posted by users.

I have 2 tables. feedback table :

id

title

category

status

details

created_by

created_on

upvotes table:

id

feedbackID (points to id of feedback table)

userID (points to id of user table)

I need help to figure out how to fetch total number of upvotes of all feedback and check if user has upvoted or not.

Right now I am just have this:

  const { data, error } = await supabase
    .from('feedback')
    .select()
    .order('created_on', { ascending: false });


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source