I need to utilize MongoDB's aggregation framework using ReactiveMongo. I only find this example which uses BSON. I would like to use JSON so I changed the code to :
def populatedStates(col: JSONCollection) = {
import col.BatchCommands.AggregationFramework.{AggregationResult, Group, Match, SumField}
val res: Future[AggregationResult] = col.aggregate(
Group(JsString("$state"))("totalPop" -> SumField("population")),
List(Match(JSONDocument("totalPop" -> JSONDocument("$gte" -> 10000000L)))))
res.map(_.firstBatch)
}
But there's no "JSONDocument" type.
What would be the correct way to finish this approach?