Created
April 8, 2012 18:12
-
-
Save distracteddev/2338881 to your computer and use it in GitHub Desktop.
Resourceful Question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
} | |
// If there are settings, update them. | |
else { | |
// Why do I need to access ._id through the ._properties field? | |
// My hunch is that there is some sort of sanitize method that | |
// brings the private properties into the actual object's properties | |
BlogSettings.update(settings[0]._properties._id, self.req.body, function(err) { | |
if (err) { | |
winston.error(err); | |
throw err; | |
} | |
self.res.end("Settings Updated\n"); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment