Social Media Like feature

0
Hello everyone, I’m trying to implement a “like functionality” similar to social media where every user will be able to like the post. And in my case when the post is posted by the user every users are able to see the post and when one user likes the post and logs out and other user signs’ in and hit the like button of the same post he is disliking the post liked by the other user. how can I refresh the like for perticular users?  I have “Post Entity” and in that I have a boolean attribute “Islike” to check whether the like is true or false and integer attribute ”Like” to keep a count on likes. Thanks in advance!! Regards, Harish
asked
2 answers
1

Your association is wrong. You must have *-* association or you dont have an association at all.

1 post will be liked by many users and 1 user can like many posts. 

If the association is wrong, then mostly the user will be using the same association that exists for another user.

answered
0

Hi Harish,

There are multiple ways to achieve it. You can have a separate entity to keep track of whether a particular post is liked by a particular account or not. That way you can like or dislike a post by altering the LinkHelper object associated with that Account for that particular Post.

Something like this:

 

You can ofcourse construct it in a different manner based upon your domain model.

answered