DEV Community

Andreas Brain
Andreas Brain

Posted on

Should I call Mongoose from the Express middleware?

When you look for tutorials about building a REST API with Express and Mongoose, the vast majority includes snippets like this:

router.get('/users', async (req, res) => {
  res.json(await User.find())
}

Is it a good practice to directly access Mongoose Models from the Express middleware without any abstraction?

Top comments (0)