How to use ReactiveMongo + JSON aggregation framework in Play Framework?
问题 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