weather-news
Version:
Implementation of Lab 9 in BYU CS 360
14 lines (11 loc) • 327 B
JavaScript
var mongoose = require('mongoose');
var PostSchema = new mongoose.Schema({
title: String,
upvotes: {type: Number, default: 0},
comments: [{type: mongoose.Schema.Types.ObjectId, ref: 'Comment' }]
});
PostSchema.methods.upvote = function(cb) {
this.upvotes += 1;
this.save(cb);
};
mongoose.model('Post', PostSchema);