title: mongodb multiple groups in one result
body: <p>I have documents similar to this stored in mongodb </p>
  
  <pre><code>{
   "_id":"transaction_id"
   "customer":"some customer",
   "order_date":Date('2011-01-01'),
   "delivery_date":Date('2011-01-15'),
   "amt":500.0,
   "qty":50
  },
  {
   "_id":"transaction_id"
   "customer":"some customer",
   "order_date":Date('2011-01-01'),
   "delivery_date":Date('2011-02-04'),
   "amt":500.0,
   "qty":50
  }
  </code></pre>
  
  <p>I am looking to do some aggregation for order date and delivery date to plot the total quantity of inventory being ordered and delivered to each customer per month.</p>
  
  <p>Granted I could run 2 aggregation queries to obtain what I want, but I was just wondering if it is possible to obtain a result that has 2 sets of groups with 1 command?</p>
  
  <p>Expected result would be like:</p>
  
  <pre><code>results:[{
   _id:{
     customer:"some customer"
   },
   orders:[
    {
     year:2011,
     month:1,
     qty:100
    },
     ...
   ]
   deliveries:[
    {
     year:2011,
     month:1,
     qty:50
    },
    {
     year:2011,
     month:2,
     qty:50
    },
    ...
   ]
  },...]
  </code></pre>