title: I am getting an error of mongoose is not defined
body: <p>I am creating an api using MongoDB, I am using Mongoose to create Data Persistence. However I am getting an error that Mongoose is not defined, I have used require function to call the node module but it is still giving me the same error.</p>
  
  <p>Below is the connection file</p>
  
  <pre><code>var mongoose = require('mongoose')
  var database = 'api'
  
  const server = 'mongodb://localhost:27017/'+database
   console.log(server)
  
  mongoose.connect(server)
  const db = mongoose.connection
  console.log(db)
  
  var Schema = mongoose.Schema
  var ObjectId = Schema.ObjectId
  
  const WeatherSchema = new Schema({
    id: {type: String, required: true},
    name: { type: String, required: true },
    items: {type: String, required: true}
   })
  
   var WeatherDB = mongoose.model('DBlist', WeatherSchema)
  </code></pre>