title: MongoDB: Querying mongo through mongoose does not work
body: <p><strong>What is the problem?</strong> I am unable to query or write to the database at all using mongoose. For example, if I try to save or add a new user the function never totally completes and it just hangs there... no errors reported (as far as I know obviously). An example is shown below.</p>
  
  <p><strong>What have I done so far?</strong> </p>
  
  <ul>
  <li>I am able to successfully connect to the mLab database using the mongo shell as well  as <code>mongoose.connect</code>. </li>
  <li>I am only able to add new users through the mongo shell. </li>
  <li>When I try to run the app locally and online, it loads fine but I hangs when I do something that querys the database. </li>
  <li>The output seems to be the same regardless of what <code>mongoose.connection.readyState</code> is (i.e. 0 or 1) without throwing an error. </li>
  <li>I have tried to open a new connection immediately prior to conducting the save function however the output is the same except it connects twice.</li>
  </ul>
  
  <p><strong>Additional Updates:</strong></p>
  
  <ul>
  <li>When I run node in debug mode, the code goes to newuser.save line and then after hitting next it goes to the end of the function and it continues to go through straight to end of numerous functions found in my modules</li>
  </ul>
  
  <p>Could this be a problem with the versions I am using?</p>
  
  <p>I am not sure what code to show but to keep it short I have included the main functions:</p>
  
  <p><strong>app.js</strong> </p>
  
  <pre><code>var conn = process.env.MONGOLAB_URI;
  var mongoConnection = mongoose.connect(conn, {useMongoClient: true}, function (err, db) {
      if (err) {
          console.log('Unable to connect to MongoDB: ', err);
  
      } else {
          console.log('Connection has been established...');
  
      }
  });
  </code></pre>
  
  <p><strong>user_controller.js</strong></p>
  
  <pre><code>module.exports.signup = function (req,res) {
  
      var newuser = new User;
  
      newuser.set('username', (req.body.username).toLowerCase() );
      newuser.set('hashed_password', hashPW(req.body.password));
      newuser.set('email', (req.body.email).toLowerCase());
      newuser.set('admin',false);
  
      debug("User information entered: " + newuser);
  
      newuser.save(function (err,newuser) {
          if (err) {
              try {
                  if (err.code==11000) res.render('signup', { message: 'Sorry, someone is using that username or email already.'} );
              } catch(e) {
                  debug(e);
              }
          } else {
              req.session.user = newuser.id;
              req.session.username = newuser.username;
              req.session.msg = 'Authenticated as ' + newuser.username;
              debug("User information saved. Redirecting...");
              res.redirect('/');
          }
      });
  
  };
  </code></pre>
  
  <p>This is what the output looks like</p>
  
  <pre><code>  Connection has been established...
    app:server User information entered: { admin: false,
    app:server   email: 'blahblah@gmail.com',
    app:server   username: 'blaaaahhh',
    app:server   _id: 5957fddbc854c056c5b695f4 } +0ms
  POST /signup - - ms - -
    app:server User information entered: { admin: false,
    app:server   email: 'blahblah@gmail.com',
    app:server   username: 'blaaaahhh',
    app:server   _id: 5957fe53c854c056c5b695f5 } +2m
  POST /signup - - ms - -
  </code></pre>