title: How to check if a document il linked to another in MongoDB
body: <p>Suppose that I have two collections:</p>
  
  <p><em>Users</em></p>
  
  <pre><code>_id:5c810da8c714a02e84d16d16
  username:foo
  </code></pre>
  
  <p><em>Tokens</em></p>
  
  <pre><code>_id: 5c81347b00370c2848db8725
  _userId: 5c810da8c714a02e84d16d16
  token: "83790bf08fa16eec1c3c6761d0c1be4f"
  </code></pre>
  
  <p>I'm trying to check if the token with id <code>5c81347b00370c2848db8725</code> is linked to the user with id <code>5c810da8c714a02e84d16d16</code>. </p>
  
  <p>The first problem is that I only have the username to find the user details, so this is my solution:</p>
  
  <pre><code>User.findOne({ username: req.body.username }, async function (err, user) {
      let token = await Token.findOne({ token: req.body.token });
  
      console.log(token._userId);
      console.log(user._id);
      console.log(token._userId != user._id);
  
      if (token == null || token._userId != user._id) {
         //Error happened..
      }
  });
  </code></pre>
  
  <p>now the code above will return the following result:</p>
  
  <pre><code>5c810da8c714a02e84d16d16
  5c810da8c714a02e84d16d16
  true
  </code></pre>
  
  <p>but should return <code>false</code> because the record are equal.. What I did wrong?</p>