Skip to content

Instantly share code, notes, and snippets.

@adicirstei
Last active August 29, 2015 14:18
Show Gist options
  • Save adicirstei/da9b55d2039e3e81dd38 to your computer and use it in GitHub Desktop.
Save adicirstei/da9b55d2039e3e81dd38 to your computer and use it in GitHub Desktop.
destroy: function(req, res) {
var id = req.param('id');
MyModel.findOne(id)
.exec(function foundRecord (err, record) {
if (err) return res.serverError(err);
if(!record) return res.notFound('No record found with the specified `id`.');
MyModel.destroy(id)
.exec(function(err) {
if (err) return res.negotiate(err);
return res.ok(record);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment