title: Stuck with Promise Pending
body: <p>Using NodeJS and Mongoose I'm trying to create a database file that allows me to query the database and return the result to be able to work with without using Mongoose.</p>
  
  <p>In my database file I have this</p>
  
  <p>db.js</p>
  
  <pre><code>module.exports = {
  
    getUser: function (name) {
      var u = User.findOne({username: name}).exec().then(function(user) {
        console.log(user);
        return user;
      });
      return u;
    }
  
  };
  </code></pre>
  
  <p>and in my other file calling it I have</p>
  
  <pre><code>var db = require('./db')
  
  var user_info = db.getUser("tom");
  console.log(user_info);
  </code></pre>
  
  <p>When the getUser function is called it correctly prints the information I'm looking for in the db.js file with the following line of code.</p>
  
  <pre><code>console.log(user);
  </code></pre>
  
  <p>However I can't seem to find a way of getting the database to return the value into user_info, I just get </p>
  
  <pre><code>Promise { &lt;pending&gt; }
  </code></pre>
  
  <p>I've looked into .then and callbacks but can't seem to figure out how to get it to work I just always end up in an endless cycle of Promise pending.</p>
  
  <p>Thanks</p>