Created
January 11, 2020 19:58
-
-
Save PatrickKalkman/29355b96636b7addd7f84a002e7a8c58 to your computer and use it in GitHub Desktop.
Update part of the JobController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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