Skip to content

Instantly share code, notes, and snippets.

@twinsdbv
Last active November 2, 2015 07:03
Show Gist options
  • Save twinsdbv/88b1304767521416927d to your computer and use it in GitHub Desktop.
Save twinsdbv/88b1304767521416927d to your computer and use it in GitHub Desktop.
// 3.2
posts.insert(post, function (err, result) {
"use strict";
if (!err) {
console.log("Inserted new post");
return callback(null, permalink);
}
return callback(err, null);
});
// 3.3
var post = this.getPostByPermalink(permalink, function (err, post) {
if (err) return callback(err, null);
posts.update({_id: post._id}, {$addToSet: {'comments': comment}}, function (err, result) {
"use strict";
if (!err) {
console.log("Inserted new comment");
return callback(null, result[0]);
} else {
return callback(err, null);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment