Skip to content

Commit

Permalink
πŸ› FIX: modelname init
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxDev810 committed Nov 17, 2023
1 parent 6a93402 commit e53cf35
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion backend/handlers/downloadHandler/downloadPdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const ObjectId = mongoose.Types.ObjectId;

module.exports = downloadPdf = async (req, res, { directory, id }) => {
try {
const modelName = directory.slice(0, 1).toUpperCase() + directory.slice(1);
if (!mongoose.models[modelName]) {
throw new Error(`Model '${modelName}' does not exist`);
}
const modelName = directory.slice(0, 1).toUpperCase() + directory.slice(1);
const Model = mongoose.model(modelName);
const result = await Model.findById(ObjectId(id)).exec();

Expand Down

0 comments on commit e53cf35

Please sign in to comment.