Skip to content

Instantly share code, notes, and snippets.

@distracteddev
distracteddev / Get Blog Posts (Broken)
Created April 8, 2012 22:31
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;
});
}
@distracteddev
distracteddev / example.js
Created April 8, 2012 18:12
Resourceful Question
BlogSettings.all(function(err, settings) {
winston.debug(JSON.stringify(settings));
if (settings == undefined) {
BlogSettings.create(self.req.body, function(err, settings) {
if (err) {
winston.error(err);
throw new(Error)(err);
}
self.res.end(JSON.stringify(settings));
winston.debug(settings);