title: Mongoose OverwriteModelError: Cannot overwrite model once compiled
body: <p>I created a module for my Mongoose models called data_models/index.js, is very simple. </p>
  
  <pre><code>var mongoose = require('mongoose'),
      Schema = mongoose.Schema,
  
      var GlobalTagsSchema = new Schema ({
          _Id: Schema.Types.ObjectId ,
          tag_name: {type: String, require: true, unique: true},
          createdDate : { type: Date, default: Date.now } ,
          alias : [{
              tag_name: {type: String},
              createdDate: {type: Date, default: Date.now}
          }]
  
      });
  
  module.exports = {
          InitDB:function(user,pass){
              var conn = mongoose.connect('mongodb://'+user+':'+pass+'@localhost/db');
              var db = mongoose.connection;
              db.on('error',console.error.bind(console, 'connection error ....'));
              db.once('open',function callback(){
                  console.log(' Database connected..');
              });
              return db ;
          },
          Global_Tagas : mongoose.model('Global_Tags', GlobalTagsSchema)
  }
  </code></pre>
  
  <p>Now when I run my test in Mocha is called then this way</p>
  
  <pre><code>   var nebulab_data_model = require('nebulab_data_models');
         nebulab_data_model.InitDB(process.env.MONGODB_USER,process.env.MONGODB_PASSWORD);
  </code></pre>
  
  <p>When I run my test I get the following error :</p>
  
  <pre><code>/Users/Tag/node_modules/mongoose/lib/index.js:334
        throw new mongoose.Error.OverwriteModelError(name);
              ^
  OverwriteModelError: Cannot overwrite `Global_Tags` model once compiled.
  </code></pre>