title: How to get rid of Error: "OverwriteModelError: Cannot overwrite `undefined` model once compiled."?
body: <p>I have a common method for updating document of any collection in MongoDB? </p>
  
  <p>The following code is in file name <strong>Deleter.js</strong></p>
  
  <pre><code>module.exports.MongooseDelete = function (schemaObj, ModelObject);
  {
    var ModelObj = new mongoose.Model("collectionName",schemaObj);
    ModelObj.remove(ModelObject);
  }
  </code></pre>
  
  <p>And invoking as follows in my main file <strong>app.js</strong>:</p>
  
  <pre><code>var ModObj = mongoose.model("schemaName", schemasObj);
  var Model_instance = new ModObj();
  var deleter = require('Deleter.js');
  deleter.MongooseDelete(schemasObj,Model_instance);
  </code></pre>
  
  <p>I am getting following error: </p>
  
  <pre><code>OverwriteModelError: Cannot overwrite `undefined` model once compiled.
      at Mongoose.model (D:\Projects\MyPrjct\node_modules\mongoose\lib\index.js:4:13)
  </code></pre>
  
  <p>I get on 2nd method call only..
  Please let me know if any one has got some solution.</p>