Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It's the first time managing Mongoose by socket.io and I'm wondering if this could be a good way:

socket.on('comment sent', function(data){
    var comment = new Comment(data);
    comment.save(function(err) {
        if (err) {
            //may be better send a custom error
            return io.emit('comment error',err);
        }
        io.emit('comment added',comment);
    });
});
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.