title: Find documents in MongoDB using result of another query
body: <p>I'm new to MongoDB and I'm trying to find documents in collection <code>A</code>, where field <code>_id</code> is equal to field <code>excel_template</code> from collection <code>B</code>.</p>
  
  <pre><code>var r = db.B.find({"name":/.*aco.*/}, {excel_template:1, _id:0}).excel_template;
  db.A.find({"_id":{$eq: "${r}" }})
  </code></pre>
  
  <p>but I have hard time doing it. It gives me no results while it should give me one result. Any suggestions will be appreciated</p>