Scala+ReactiveMongo db.runCommand("serverStatus")

Scala+ReactiveMongo db.runCommand("serverStatus")

如何在 Scala 2.11.4 中 运行 db.runCommand("serverStatus")?我正在使用 play2-reactivemongo 0.10.5.0.akka23 ? db.command 在 reactiveMongo 中获取 RawCommand,后者又是一个 BSONDocument。如何 运行 数据库命令,如 db.serverStatus() 或 db.printShardingStatus()

谢谢

找到解决方案:

def statusCheck(dbConn: String = "db"): Future[JsObject] = {
val commandDoc =
  BSONDocument(
    "serverStatus" -> 1)
val result  = db.command(RawCommand(commandDoc))
result.map { doc =>
  Json.toJson(doc).asInstanceOf[JsObject]
} }