Comments.js 535 B

12345678910111213141516171819202122232425
  1. var mongoose = require('mongoose');
  2. var schemaOptions = {
  3. timestamps: true,
  4. toJSON: {
  5. virtuals: true
  6. }
  7. };
  8. var commentSchema = new mongoose.Schema({
  9. date: Date,
  10. comments: [{
  11. body: String,
  12. date: Date
  13. creator: { type : mongoose.Schema.ObjectId, ref : 'User' }
  14. }],
  15. attachedToUser: { type : mongoose.Schema.ObjectId, ref : 'User' },
  16. attachedToWatch: { type : mongoose.Schema.ObjectId, ref : 'Watch' },
  17. }, schemaOptions);
  18. var Comment = mongoose.model('Comment', commentSchema);
  19. module.exports = Comment;