title: Return results mongoose in find query to a variable
body: <p>I need to return the results of a query with mongoose in node.js.</p>
  
  <p>How do you return the value to set the value to a variable?</p>
  
  <p>What I need to do is: </p>
  
  <pre><code>var results = users.findOne({_id : users_list[i]['user_id']},{email : 1, credits : 1},{}, function(err, docs) {
      if( err || !docs) {
          console.log("No user found");
      } else {            
          return docs;
      };
  });
  </code></pre>
  
  <p>In order to have:</p>
  
  <pre><code>results = docs 
  </code></pre>
  
  <p>Thanks a lot for your reply .</p>
  
  <p>I also have another problem.</p>
  
  <p>How to pass variable in a query operator with find or findOne? Like : </p>
  
  <pre><code>var foo = "Blaa";
  
  users.findOne({_id : users_list[i]['user_id']},{email : 1, credits : 1},{}, function(err, docs) {
      if( err || !docs) {
          console.log("No user found");
      } else {
          // I want to use the foo variable here
          console.log(foo);
      };
  });
  </code></pre>