A couple of tricks for using MongoDB’s
$set operator, dealing with properties that contain dots for creating a basic rating system:
$set will set the value or update it. So you don’t have to worry about repeat voters! They simply will change their vote and not skew your results. If you don’t want the users to be able to vote twice then you can simply disable the link to vote on the page by looking for the IP in the array of ratings. Which, yes, is a simple deterrent and the user could technically lift the URL to hit to make the request to vote again…But again, your results aren’t skewed and if you need further protection you can come up with something else.
Atomic increments are not available in all NoSQL databases, so if your application needs it make sure you include it early on the checklist.
Original title and link: Creating a Simple and Efficient Rating System with MongoDB (NoSQL databases © myNoSQL)