title: Can you fake a join in Mongo aggregation
body: <p>I have documents of the form</p>
  
  
  
  <pre class="lang-javascript prettyprint-override"><code>members:
      {
      _id:ObjectId("xxx"),
      name:"John",
      branch:ObjectId("yyy")
      }
  
  branches:
      {
      _id:ObjectId("yyy"),
      name:"Branch A"
      }
  </code></pre>
  
  <p>I want to report on the number of people in each branch.  A straight $group pipeline does this but I can only get it to report back the branch _id and then convert it in my code.  I would like to do something like:</p>
  
  <pre class="lang-javascript prettyprint-override"><code>db.members.aggregate(
      {$group:{_id:db.branches.findOne(
          {_id:"$branch"},
          {name:1}).name,count:{$sum:1}}})
  </code></pre>
  
  <p>Which appears not to work.  Is there something along those lines that does work?</p>