Skip to content

Instantly share code, notes, and snippets.

@goish135
Created December 19, 2021 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goish135/dfb72c826ae47c1237ab05e6d508065b to your computer and use it in GitHub Desktop.
Save goish135/dfb72c826ae47c1237ab05e6d508065b to your computer and use it in GitHub Desktop.
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