Created
July 12, 2020 11:23
-
-
Save atakangah/71b4b470f2a7b120bb75a91a3b57f1a0 to your computer and use it in GitHub Desktop.
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
async function updateCompletedStudents(courseId, student, res) { | |
/* | |
* Substract -1 from @continuingStudents on system | |
*/ | |
try { | |
//Get current system data | |
let system = await System.find({ 'systemId': SYSTEM_ID }).exec(); | |
//Substract -1 from continuingStudents | |
system[0].continuingStudents -=1; | |
try { | |
//Update new system status | |
await System.updateOne({ 'systemId': SYSTEM_ID }, system[0], { upsert: true }).exec(); | |
} catch (error) { | |
console.log(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