Vulcan/server/comment.js
2012-09-20 08:09:45 +09:00

21 lines
511 B
JavaScript

Meteor.methods({
comment: function(post_id, parentComment_id, text){
var user = Meteor.users.findOne(this.userId());
var comment = {
post: post_id
, body: text
, user_id: user._id
, submitted: new Date().getTime()
};
if(parentComment_id)
comment.parent = parentComment_id;
var new_comment_id=Comments.insert(comment);
Posts.update(post_id, {$inc: {comments: 1}});
Meteor.call('upvoteComment', new_comment_id);
return new_comment_id;
}
});