title: Getting cannot read property 'users' of undefined while creating mongoose model
body: <p>I am trying to create a mongoose model and using it to get the data from the mongodb, but I am getting the exception </p>
  
  <p>My mongoose version from package.json is :<strong>"mongoose": "4.5.5"</strong></p>
  
  <pre><code>TypeError: Cannot read property 'users' of undefined
  </code></pre>
  
  <p>Now here is my demo code:</p>
  
  <pre><code>var mongoose  =   require("mongoose");
  var schema    =   mongoose.Schema;
  var Users = {
      _id         :   {
          type        :   String,
          require     :   true
      },
      username    :   {
          type        :   String,
          required    :   true
      },
      password    :   {
          type        :   String,
          required    :   true
      }
  };
  var UsersModel  =   new mongoose.model('users', Users);
  var newUser = new UsersModel({"username":"A", "password":"V"});
  newUser.save(function(err, result){
      if(err){
          console.log('&gt;&gt;&gt;&gt;&gt;&gt; Error');
      }else{
          console.log('&gt;&gt;&gt;&gt;&gt;&gt; ' + JSON.stringify(result, null, 4));
      }
  });
  </code></pre>
  
  <p>And here is the error :</p>
  
  <pre><code>/home/ankur/Private/Work/ps/node_modules/mongoose/lib/index.js:343
  if (!this.modelSchemas[name]) {                                                                         
                          ^                                                                                 
  TypeError: Cannot read property 'users' of undefined                                                      
      at new Mongoose.model (/home/ankur/Private/Work/ps/node_modules/mongoose/lib/index.js:343:25)         
      at Object.&lt;anonymous&gt; (/home/ankur/Private/Work/ps/models_mongoose/Users.model.js:24:21)              
      at Module._compile (module.js:456:26)                                                                 
      at Object.Module._extensions..js (module.js:474:10)                                                   
      at Module.load (module.js:356:32)                                                                     
      at Function.Module._load (module.js:312:12)                                                           
      at Function.Module.runMain (module.js:497:10)                                                         
      at startup (node.js:119:16)                                                                           
      at node.js:929:3                  
  </code></pre>
  
  <p>Now my question is in this code I have hardly done anything extra, just configured the schema, created a new model on that schema and saved it.
  So where I missed the stuff?</p>
  
  <p>Please shed some views.</p>