middleware/database.js
//Connecting to MongoDB database and we are using our database name which is database
Connecting to MongoDB database and we are using our database name which is database
Connecting to MongoDB database and we are using our database name which is database
async function database(req, res, next) {
  if (!client.isConnected()) await client.connect();
  req.dbClient = client;
  req.db = client.db("database"); 
  return next();
}
async function database ( req , res , next ) { if ( ! client . isConnected ( ) ) await client . connect ( ) ; req . dbClient = client ; req . db = client . db ( "database" ) ; return next ( ) ; }
Connecting to MongoDB database and we are using our database name which is database
Connecting to MongoDB database and we are using our database name which is database
//The name of our database is called database so that is what we are connecting to