title: How to perform a complex query in MongoDB
body: <p>I want to perform a query on this schema:</p>
  
  <pre><code>{ 
     "name" : "xxx",
     "guests" : [ 
         {
              "category" : "category 1",
              "arrived" : false
         },
         {
              "category" : "category 2",
              "arrived" : false
         },
         {
              "category" : "category 1",
              "arrived" : true
         },
         {
              "category" : "category 2",
              "arrived" : true
         }
     ]
  }
  </code></pre>
  
  <p>I want to get for a certain name, a list with the percentage of guests arrived for each category.</p>
  
  <p>For the document above as example, I want to receive: </p>
  
  <pre><code>{
      name : "xxx",
      results : [
           {
                category : "category 1",
                arrived : 50 (percent)
           },
           {
                category : "category 2",
                arrived : 50 (percent)
           },
      ]
  </code></pre>
  
  <p>Is there a way to do this with a single MongoDB query? Also, should I do this computation in the client-side or server-side?</p>