Create single like count per user

Hey Adalo Friends, I am designing a product hunt lookalike and i run into an issue.

When I created the vote counter, It keeps counting for everyclick. but i want one user to be able to vote once.

Here’s a video to the app.

Do let me know how i can fix this. Thank you.

Hello, you should add a “Liked By” relationship property between users and posts, so once an user hit the like button, update current post - liked by - add logged in user, then add +1 on the counter only if (advanced - sometimes ) current post - liked by - does not contain - logged in user.
Hope that helped

2 Likes

Hi Paul,

You can create a many to many relationship and add logged in user there and make the counter update action conditional. Oh Eugen already answered! :+1:

Thank you

2 Likes

Thanks It worked. The many to many relationships was what I needed instead of creating an extra collection. Thank you

1 Like

Thank you Eugen, it worked.