我需要使用 ReactiveMongo 来利用 MongoDB 的聚合框架。我只发现这个使用 BSON 的例子。我想使用 JSON,所以我将代码更改为:
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)
}
但是没有“JSONDocument”类型。
完成这种方法的正确方法是什么?