title: ReferenceError 'model' is not defined in mongoose
body: <p>I am trying to write a basic mongoose application which has a schema. I had also created a model.
  The code is as follows.`enter code here \</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var mongoose=require('mongoose');
  dbUrl='mongodb://localhost:27017/trial';
  mongoose.connect(dbUrl);
  
  var userSchema=new mongoose.Schema({
   name:String,
   email:String,
   createdOn:Date
  },{collection:'users'});
  
  mongoose.model('User', userSchema);
  var newUser=new User({name:'Simon',
   email:'simon@simon.com',
   createdOn:Date.now()
  });
  
  newUser.save(function(err){
   if(!err){
    console.log('User Saved');
   }
  });
  
  
  console.log(userOne.name);
  
  
  mongoose.connection.on('connected',function(){
   console.log('Mongoose connected'+dbUrl);
  });
  
  mongoose.connection.on('error',function(err){
   console.log('Error'+err);
  });
  
  mongoose.connection.on('disconnected',function(){
   console.log('disconnected');
  
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>`
   But when I tried to instantiate the model, 
  I'm getting the following error.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var newUser=new User({name:'Simon',
                  ^
  ReferenceError: User is not defined
      at Object.&lt;anonymous&gt; (C:\Users\jijebara\Desktop\IoT\Node+Mongo\m_app.js:12:
  17)
      at Module._compile (module.js:460:26)
      at Object.Module._extensions..js (module.js:478:10)
      at Module.load (module.js:355:32)
      at Function.Module._load (module.js:310:12)
      at Function.Module.runMain (module.js:501:10)
      at startup (node.js:129:16)
      at node.js:814:3</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am also sure that the connections are sure since the console messages in connection.on work properly.</p>
  
  <p>Any ideas on how to solve this ..
  Thanks in advance..</p>