title: storing upvotes/downvotes in mongodb
body: <p>I have a collection of <code>Posts</code> and <code>Users</code> where users can upvote/downvote each post. What would be the best way to store this in a mongodb database to make sure that users cannot vote for a given document more than once? </p>
  
  <p>The simplest nosql-ish solution I came up with is storing an array of user_ids who voted inside each <code>Post</code> document (or even array of <code>(user_id, vote)</code> where <code>vote</code> is +1 or -1 so that users will be able to change their vote). Is it a good idea from the performance standpoint given that each post can have thousands of votes?</p>
  
  <p>What about really popular websites like Reddit where top posts can have hundreds of thousands of votes?</p>