UNPKG

weather-news

Version:

Implementation of Lab 9 in BYU CS 360

12 lines (11 loc) 326 B
var mongoose = require('mongoose'); var CommentSchema = new mongoose.Schema({ body: String, upvotes: {type: Number, default: 0}, post: {type: mongoose.Schema.Types.ObjectId, ref:'Post' } }); CommentSchema.methods.upvote = function(cb) { this.upvotes += 1; this.save(cb); }; mongoose.model('Comment', CommentSchema);