Last active
July 12, 2020 11:08
-
-
Save atakangah/aebb55cd22d36ebdcc417ad5a05f8006 to your computer and use it in GitHub Desktop.
<<Continuation>>An express routing js file to take a student's Id and a course Id from a request body to the api server and remove the associated course with the specified course Id from the student's courses list<<Continuation>>
This file contains 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
// Update student data with new data without the deleted course | |
try { | |
let ccompleteRes = await Students.updateOne({ 'studentId': studentId }, student[0], { upsert: true }).exec(); | |
/* | |
* NOTICE THE CALL TO THIS FUNCTION | |
* I DID NOT USE AWAIT | |
*/ | |
updateCompletedStudents(courseId, student, res); | |
if( ccompleteRes.ok ) | |
return res.status(200).send({ | |
payload: `Course wth Id ${courseId} completed for ${student[0].firstName}` | |
}); | |
} catch(error) { | |
res.status(Errors.DATABASE.DOC_UPDATE_OP_FAILED.CODE).send({ | |
detail: Errors.FATAL_ERROR_MESSAGE | |
}); | |
} | |
} | |
} catch(error) { | |
res.status(Errors.DATABASE.DOC_READ_OP_FAILED.CODE).send({ | |
detail: Errors.FATAL_ERROR_MESSAGE | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment