Skip to content

Instantly share code, notes, and snippets.

@PatrickKalkman
Created January 11, 2020 19:58
Show Gist options
  • Save PatrickKalkman/29355b96636b7addd7f84a002e7a8c58 to your computer and use it in GitHub Desktop.
Save PatrickKalkman/29355b96636b7addd7f84a002e7a8c58 to your computer and use it in GitHub Desktop.
Update part of the JobController
jobController.updateJob = function updateJob(req, reply) {
const id = req.params.id;
const job = req.body;
const { ...updateData } = job;
Job.findByIdAndUpdate(id, updateData, { new: true }, function(err, job) {
if (!err) {
if (job) {
reply.send(job);
} else {
reply.notFound(`Could not find job with id ${id}`);
}
} else {
reply.badRequest(err);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment