K
K
Kt0T02021-04-29 23:59:58
Python
Kt0T0, 2021-04-29 23:59:58

How to disable likes?

I am making a system of likes, I can’t figure out how to forbid re-like a post, when I click on the like, I get postid and userid, how can I link all this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-04-30
@Kt0T0

There is a database, I hope?
A like is a classic many-to-many relationship between posts and users.
Those. in addition to the table of posts and the table of users, you make a connected table of two fields - post id and user id. If there is a post in it, the user liked the post. Then you can
a) check in advance if there is such a record, and show "you have already liked"
b) ignore repeated likes if they do come. Just make a couple of user-posts as a key
c) as a bonus - you can count the number of likes for a post and choose what a particular user liked.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question