title: How to use ReactiveMongo + JSON aggregation framework in Play Framework?
body: <p>I need to utilize MongoDB's aggregation framework using ReactiveMongo. I only find <a href="http://reactivemongo.org/releases/0.11/documentation/advanced-topics/aggregation.html" rel="nofollow">this example</a> which uses BSON. I would like to use JSON so I changed the code to :</p>
  
  <pre><code>def populatedStates(col: JSONCollection) = {
    import col.BatchCommands.AggregationFramework.{AggregationResult, Group, Match, SumField}
    val res: Future[AggregationResult] = col.aggregate(
      Group(JsString("$state"))("totalPop" -&gt; SumField("population")),
      List(Match(JSONDocument("totalPop" -&gt; JSONDocument("$gte" -&gt; 10000000L)))))
    res.map(_.firstBatch)
  }
  </code></pre>
  
  <p>But there's no "JSONDocument" type.</p>
  
  <p>What would be the correct way to finish this approach?</p>