Ajout initial des fichiers du projet
This commit is contained in:
Executable
+19
@@ -0,0 +1,19 @@
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
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, toJSON: { virtuals: true } });
|
||||
|
||||
// Requires population of author
|
||||
CommentSchema.methods.toJSONFor = function (user) {
|
||||
return {
|
||||
id: this._id,
|
||||
body: this.body,
|
||||
createdAt: this.createdAt,
|
||||
author: this.author.toProfileJSONFor(user)
|
||||
};
|
||||
};
|
||||
|
||||
mongoose.model('Comment', CommentSchema);
|
||||
Reference in New Issue
Block a user