Created
December 19, 2021 14:39
-
-
Save goish135/dfb72c826ae47c1237ab05e6d508065b 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
exports.addNewClass = async (req, reply) => { | |
try { | |
let classname = new class_name(req.body) | |
const className = req.body | |
console.log(className.class_name) | |
const duplicateData = await class_name.findOne({"class_name":className.class_name}) | |
console.log("duplicateData:"+duplicateData) | |
if(!duplicateData){ | |
let newclass = await classname.save() | |
return newclass | |
}else{ | |
return "Duplicated class_name!" | |
} | |
} catch (err) { | |
throw boom.boomify(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment