title: MongoDB : querying documents with two equal fields, $match and $eq
body: <p>What is the best way to return all documents in a collection if I want document.a == document.b?</p>
  
  <p>I've tried </p>
  
  <pre><code>db.collection.aggregate([ { $match: { $eq: [ '$a', '$b' ] } }])
  </code></pre>
  
  <p>But it returns with no errors or results, because I assume it is literally matching strings "$a" and "$b".  Is there a different way to specify that these are fields?</p>
  
  <pre><code>db.collection.aggregate([    { $project: { 
      eq: { $cond: [ { $eq: [ '$a', '$b' ] }, 1, 0 ] } 
  } },
  { $match: { eq: 1 } }])
  </code></pre>
  
  <p>The above works, but requires the additional step of querying again with whatever documents it found or projecting all possible fields.</p>
  
  <p>Is there a better way for achieving this query?</p>