MA
You don't need to create the middlewear to just check if video exists or not, you simply call the const video=Video.findByIdAndDelete(id); if(!video) res.status(404).json({message:"Video not found"}) and letter the success response comes, this is more better approach
CommentArticleJun 3, 2025Optimizing Express Middleware: Passing Data via req to Avoid Extra DB Queries