Hello.
I have Users and Item data object. I want to create rating system for items when user clicks “like” and rating is incrementing.
No problem to make it. But how to forbid vote twice for user? I need possibility to vote only once for each item.
I have idea to save users ids to item, but it looks awkward and uncomfortable. I believe that there is a simple and beautiful way.
well we can maybe share a bit, i am working on the same system… but a bit different…
If I were you I would create a ‘Rate’ table saving the user objectId, the rate, and the object to rate objectId… and if a vote is found when you fetch your datas, it updates the vote according to user’s change.
I am creating a rating system from 0 to 5, I use a table as described earlier, and I make all the treatment on the device to calculate the global rate (from 0 to 5) and fill 6 ProgressView on my UI (from 0 to 5 to see at a glance the repartition of the votes)…
But mine is different… not all of my users will have an account… so I want do it with a combination of deviceID and objectId (not sure I can, but i am trying…)
Really nice idea. Thank you!