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
// 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); |
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
try { | |
let student = await Students.find({ 'studentId': studentId }).exec(); | |
/* | |
* After finding the student with the provided studentId, | |
* Use O(n) algorithm to find the course to complete for student | |
* It is unlikely for any student to have more than 5 courses in its course list at aytime | |
* Therefore, O(n) algorithm is ok | |
*/ |
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
router.post('/complete-student-course', async (req, res) => { | |
let {studentId, courseId} = req.body; |
NewerOlder