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);

@@ -152,41 +152,97 @@
   re
-f: 'NewsItem',%0A    required: true
+quired: true%0A  %7D,%0A  itemType: %7B%0A    type: String,%0A    required: true,%0A    default: 'news'
 %0A  %7D
@@ -373,24 +373,48 @@
 quired: true
+,%0A    min: 1,%0A    max: 1
 %0A  %7D%0A%7D);%0A%0A//

add some vote safety into the votes model and generalize it so it can be used for comments in the future