---
title: "Comment by Mohammed Arafat on \"Optimizing Express Middleware: Passing Data via req to Avoid Extra DB Queries\" | Hashnode"
description: "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"
url: "https://hashnode.com/posts/optimizing-express-middleware-passing-data-via-req-to-avoid-extra-db-queries/6835eb2a07b1990086c5e7bc/comment/683f2e0f007d12c244379c67"
---

[Discussion](https://hashnode.com/posts/optimizing-express-middleware-passing-data-via-req-to-avoid-extra-db-queries/6835eb2a07b1990086c5e7bc)

Comment [Optimizing Express Middleware: Passing Data via req to Avoid Extra DB Queries](https://hashnode.com/posts/optimizing-express-middleware-passing-data-via-req-to-avoid-extra-db-queries/6835eb2a07b1990086c5e7bc)

[Mohammed Arafat](https://hashnode.com/@MohammedArafat)

[Jun 3, 2025](https://hashnode.com/posts/optimizing-express-middleware-passing-data-via-req-to-avoid-extra-db-queries/6835eb2a07b1990086c5e7bc/comment/683f2e0f007d12c244379c67)

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
