Skip to content

Instantly share code, notes, and snippets.

@distracteddev
Created April 8, 2012 22:31
Show Gist options
  • Save distracteddev/2340126 to your computer and use it in GitHub Desktop.
Save distracteddev/2340126 to your computer and use it in GitHub Desktop.
Resourceful Question (GET)
exports.getBP = function(id) {
var self = this;
if (arguments.length < 2) {
BlogPost.all(function(err, docs) {
if (err) throw err;
self.res.end(JSON.stringify(docs) + '\n');
winston.debug(docs);
return docs;
});
}
else {
console.log('ID: ' + id);
BlogPost.get(id, function(err, post) {
if (err) throw err;
self.res.end(JSON.stringify(post) + '\n');
winston.debug(post);
return post;
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment