Scala + ReactiveMongo db.runCommand(" serverStatus")

时间:2015-04-01 21:36:03

标签: scala reactivemongo

如何在scala 2.11.4中运行db.runCommand(“serverStatus”)?我正在使用play2-reactivemongo 0.10.5.0.akka23? db.command在ActivationMongo中接受RawCommand,而反向移动又是BSONDocument。如何运行数据库命令,如db.serverStatus()或db.printShardingStatus()

由于

1 个答案:

答案 0 :(得分:1)

找到解决方案:

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]
} }