Vulcan/server/comment.js
2012-08-31 19:41:54 -04:00

18 lines
431 B
JavaScript

Meteor.methods({
comment: function(post, parentComment, text){
var user = Meteor.users.findOne(this.userId());
var comment = {
post: post._id
, body: text
, submitter: user.username
, submitted: new Date().getTime()
};
if(parentComment)
comment.parent = parentComment._id;
Comments.insert(comment);
Posts.update(post._id, {$inc: {comments: 1}});
return true;
}
});