Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var mongoose = require('mongoose');
- // schema
- var CommentSchema = new mongoose.Schema({
- body: String,
- author: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
- article: { type: mongoose.Schema.Types.ObjectId, ref: 'Article' }
- }, {timestamps: true});
- CommentSchema.methods.toJSONFor = function(user){
- return {
- id: this._id,
- body: this.body,
- createdAt: this.createdAt,
- author: this.author.toProfileJSONFor(user)
- };
- };
- mongoose.model('Comment', CommentSchema);
Advertisement
Add Comment
Please, Sign In to add comment