title: TypeError: Model is not a Constructor
body: <p>Making a MongoDB call from a react component on Form Submit with Mongoose throws an error - TypeError: Group is not a constructor at below line</p>
  
  <pre><code>let group1 = new Group
  </code></pre>
  
  <p>I have a server file inside which I initialize the connection.</p>
  
  <p><strong>server.js</strong></p>
  
  <pre><code>const mongoose = require('mongoose');
  mongoose.connect('dbName',{ useNewUrlParser: true });
  mongoose.connection.once('open',() =&gt;{
      console.log('connected to the database');
  });
  </code></pre>
  
  <p>Then there is a model file called <strong>group.js</strong></p>
  
  <pre><code>const mongoose = require('mongoose');
  
  var groupSchema = new mongoose.Schema({
      groupName: String
  });
  
  module.exports = mongoose.model('Group',groupSchema);
  </code></pre>
  
  <p><strong>Component CreateNew</strong></p>
  
  <pre><code>const Group = require('../models/group');
  
  class CreateNew extends Component {
  // code here
  render()
  // code here
  
  &lt;Form onSubmit = {e =&gt; {
  
      let group1 = new Group({
      groupName: 'My Group'
      });
      group1.save(function(err,group1){
          if (err) return console.log(err);
          console.log('mongo success');
      });
  
  }}&gt;
  </code></pre>
  
  <p>When I put all the code in one place like <a href="https://mongoosejs.com/docs/index.html" rel="nofollow noreferrer">this</a> inside the server.js file then the code works and I can see the data in Mongo.</p>
  
  <p>If I just shift the code from inside Form's onSubmit to before the 'class CreateNew extends Component' line just for testing then it throws following error</p>
  
  <blockquote>
    <p>Cannot overwrite <code>Group</code> model once compiled.</p>
  </blockquote>
  
  <p>at this line </p>
  
  <pre><code>module.exports = mongoose.model('Group',groupSchema);
  </code></pre>