Skip to content

Instantly share code, notes, and snippets.

@ayxos
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save ayxos/8813302 to your computer and use it in GitHub Desktop.

Select an option

Save ayxos/8813302 to your computer and use it in GitHub Desktop.
PUT - DELETE
exports.putById = function (req, res){
console.log(req.body);
regModel.findById(req.params.id, function (err, entry) {
for (key in req.body){
entry[key] = req.body[key];
}
entry.save(function (err) {
if (!err) {
console.log("updated");
res.send(201, {});
} else {
console.log(err);
res.send(500, "updated error");
}
});
});
};
exports.deleteById = function (req, res){
console.log('DELETED: ' + req.params.id);
regModel.findById(req.params.id, function (err, entry) {
entry.remove(function (err) {
if (!err) {
console.log("removed");
res.send(201, "Removed: " + req.params.id);
} else {
console.log(err);
res.send(500, "removed error");
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment