title: MongoDB using an array of IDs from one Collection to filter the results based on the IDs from another Collection
body: <p>Suppose there is a MongoDB Collection <code>CollA</code>. Say <code>CollA</code> has the following three Documents:</p>
  <pre class="lang-json prettyprint-override"><code>{&quot;_id&quot;: &quot;1&quot;, &quot;name&quot;: &quot;Bob&quot;},
  {&quot;_id&quot;: &quot;2&quot;, &quot;name&quot;: &quot;John&quot;},
  {&quot;_id&quot;: &quot;3&quot;, &quot;name&quot;: &quot;Will&quot;}
  </code></pre>
  <p>Let's say there is another MongoDB Collection <code>CollB</code> which has the following Document:</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;_id&quot;: &quot;1&quot;, 
      &quot;foo&quot;: {
          &quot;arr&quot;: [&quot;1&quot;, &quot;3&quot;]
      }
  }
  </code></pre>
  <p>Is there a way in MongoDB to query <code>CollB</code> for the <code>foo.arr</code> array contents (<code>[&quot;1&quot;],[&quot;3&quot;]</code>) and use it to retrieve the Documents in <code>CollA</code> which have these <code>_id</code> values, to produce the following result:</p>
  <pre class="lang-json prettyprint-override"><code>{&quot;_id&quot;: &quot;1&quot;, &quot;name&quot;: &quot;Bob&quot;},
  {&quot;_id&quot;: &quot;3&quot;, &quot;name&quot;: &quot;Will&quot;}
  </code></pre>