title: Comparing mongoose _id and strings
body: <p>I have a node.js application that pulls some data and sticks it into an object, like this:</p>
  
  <pre><code>var results = new Object();
  
  User.findOne(query, function(err, u) {
      results.userId = u._id;
  }
  </code></pre>
  
  <p>When I do an if/then based on that stored ID, the comparison is never true:</p>
  
  <pre><code>if (results.userId == AnotherMongoDocument._id) {
      console.log('This is never true');
  }
  </code></pre>
  
  <p>When I do a console.log of the two id's, they match exactly:</p>
  
  <pre><code>User id: 4fc67871349bb7bf6a000002 AnotherMongoDocument id: 4fc67871349bb7bf6a000002
  </code></pre>
  
  <p>I am assuming this is some kind of datatype problem, but I'm not sure how to convert results.userId to a datatype that will result in the above comparison being true and my outsourced brain (aka Google) has been unable to help.</p>