-1

I have two tables one for post and one for likes. Post table stores all the post information. Likes table has 3 columns

id, post_id user_id

Now I need help to figure out how to get total number of likes of each post through supabase query. I am using react for frontend.

const { data, error } = await supabase
        .from('feedback')
        .select()
        .order('created_on', { ascending: false });
ChidG
  • 3,053
  • 1
  • 21
  • 26
  • What have you tried so far. StackOverflow isn't a code writing service, you have to put in something to get something out. – Nick Bailey Mar 07 '22 at 07:33
  • this is what is I have written : const { data, error } = await supabase .from('feedback') .select() .order('created_on', { ascending: false }); – Agraj Yadav Mar 07 '22 at 11:39
  • I am not asking you to code the whole APP. I am just asking about that particular query to get total likes count. – Agraj Yadav Mar 07 '22 at 11:41

1 Answers1

0

Have you created a supabase client for your project?

if not follow this Doc https://github.com/supabase/supabase-js

Then import the client into the file you want to retrieve data.

you have left .select() empty. select can be combined with modifiers for example, you can...

const { data, error } = await supabase
  .from('feedback')
  .select(`post_id`)`

DOCs for reference: https://supabase.com/docs/reference/javascript/select

You may want to have your likes and post ids on the same table to save yourself from issues. Maybe add another column.

id, post_id user_id, post_likes

however your question is very broad hope this can point you in some of the right directions.

KeoooDev
  • 528
  • 4
  • 14