title: unmarshall aggregate result with Jongo
body: <p>I am using the MongoDB aggregate framework to query a document, the results is the following:</p>
  
  <pre><code>{
          "result" : [
                  {
                          "_id" : "luke",
                          "times" : 8
                  },
                  {
                          "_id" : "albert",
                          "times" : 4
                  },
                  {
                          "_id" : "matt",
                          "times" : 4
                  }
          ],
          "ok" : 1
  }
  </code></pre>
  
  <p>As you can see from the result above, the query works in the mongoDB shell, but I have a problem when getting the results with Jongo:</p>
  
  <pre><code>        Aggregationoutput = 
                  gamesCollection.aggregate(
                  "{ ... }"
                  ).as(Aggregation.class);
          output.results().iterator().hasNext();
  </code></pre>
  
  <p>The main problem seems to be that Jongo doesn't allow me to use <code>AggregationOutput</code>? he wants instead <code>Aggregation</code> ... but can't find any example available on how to use it</p>
  
  <p><strong>EDIT:</strong>
  I am a bit frustrated that I can't make Jongo to work with the aggregate. I had to write the query with <code>DBObjects</code> as specified in the MongoDB Java driver, but the code looks really ugly..</p>
  
  <p><strong>EDIT2:</strong>
  Just to complete the information, this is the original aggregate I was using with Jongo which could not unmarshall to ResultObject</p>
  
  <pre><code>List&lt;ResultObject&gt; output = 
                  gamesCollection.aggregate(
                  "{ $match: { 'playersList.playerid': 'bob' }},"
                  +"{ $unwind: '$playersList' },"
                  +"{ $match: { 'playersList.playerid':  { $ne: 'bob' } } },"
                  +"{ $group: { _id: '$playersList.playerid', times: { $sum : 1} } },"
                  +"{ $sort: { times: -1 } }"
                  ).as(ResultObject.class);
  
  class ResultObject{
    String _id;
    int times;
  }
  </code></pre>
  
  <p>}</p>