old_contents: var mongoose = require('mongoose')
    , Schema = mongoose.Schema;
  
  
  var voteSchema = new mongoose.Schema({
    item: {
      type: Schema.Types.ObjectId,
      ref: 'NewsItem',
      required: true
    },
    voter: {
      type: String,
      ref: 'User',
      required: true
    },
    amount: {
      type: Number,
      default: 1,
      required: true
    }
  });
  
  // each user can only vote on an item once
  voteSchema.index({ item: 1, voter: 1 }, { unique: true });
  
  module.exports = mongoose.model('Vote', voteSchema);
  
new_contents: var mongoose = require('mongoose')
    , Schema = mongoose.Schema;
  
  
  var voteSchema = new mongoose.Schema({
    item: {
      type: Schema.Types.ObjectId,
      required: true
    },
    itemType: {
      type: String,
      required: true,
      default: 'news'
    },
    voter: {
      type: String,
      ref: 'User',
      required: true
    },
    amount: {
      type: Number,
      default: 1,
      required: true,
      min: 1,
      max: 1
    }
  });
  
  // each user can only vote on an item once
  voteSchema.index({ item: 1, voter: 1 }, { unique: true });
  
  module.exports = mongoose.model('Vote', voteSchema);
  
subject: add some vote safety into the votes model and generalize it so it can be used for comments in the future