Skip to content

Instantly share code, notes, and snippets.

@distracteddev
Created April 8, 2012 18:12
Show Gist options
  • Save distracteddev/2338881 to your computer and use it in GitHub Desktop.
Save distracteddev/2338881 to your computer and use it in GitHub Desktop.
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);
});
}
// 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