Skip to content

Instantly share code, notes, and snippets.

@akorchev
Forked from burkeholland/destructuring.js
Last active August 9, 2017 15:01
Show Gist options
  • Save akorchev/869329b2b07dac3356dc563a5185995f to your computer and use it in GitHub Desktop.
Save akorchev/869329b2b07dac3356dc563a5185995f to your computer and use it in GitHub Desktop.
function update(req, res) {
const { id, name, saying } = req.body;
Hero.findOne({ id }, (err, hero) => {
if (err) {
res.status(500).send(err);
} else if (!hero) {
res.status(500).send("Hero not found");
} else {
hero.name = name;
hero.saying = saying;
hero.save()
.then(() => res.json(hero))
.catch(err => res.status(500).send(err));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment