title: How to get data from mongodb using _id.$oid object?
body: <p>I am trying to find objects with logged-in user id. </p>
  
  <pre><code>function getItems(req, res) {
      var userId = JSON.stringify(req.user._id);
  
      Items.find({user_id: userId}, function(err, items) {
          if (err) {
              res.send(err)
          }
          else {
              res.json(items);
          }
      }); 
  }
  
  // Logged-in user
  app.get('/userItems', isLoggedIn, function(req, res) {
      getItems(req, res);
  });
  </code></pre>
  
  <p>User json data looks like:</p>
  
  <pre><code>"_id": {
       $oid": "55c772bce97e9a500b3754ae"
  }
  </code></pre>
  
  <p>Item object is such:</p>
  
  <pre><code>{
      "_id": {
          "$oid": "55d086a182377f840844ee78"
      },
      "user_id": "55c772bce97e9a500b3754ae",
      itemSpecs:[
          //...
      ]
  }
  </code></pre>
  
  <p>It returns empty array because userId doesn't match to user_id I guess. As I try to set:</p>
  
  <pre><code>var userId = '55c772bce97e9a500b3754ae';
  </code></pre>
  
  <p>It returns the items with the userId. </p>
  
  <pre><code>var userId = JSON.stringify(req.user._id);
  console.log(typeof userId); // &gt;&gt; String
  </code></pre>
  
  <p>So, userId from user object and user_id from items object are same type: String.</p>
  
  <p>Probably this is really stupid but I can't see the reason why the user <strong>_id</strong> object doesn't match to <strong>user_id</strong> in items object. </p>
  
  <p>How could I get items which have logged-in user id with using logged-in user id from _id.$oid object?</p>