2015-04-01 2 views
0

Как запустить db.runCommand ("serverStatus") в scala 2.11.4? Я использую play2-reactivemongo 0.10.5.0.akka23? Db.command принимает RawCommand в reactiveMongo, который, в свою очередь, является BSONDocument. Как запускать команды базы данных, такие как db.serverStatus() или db.printShardingStatus()Scala + ReactiveMongo db.runCommand ("serverStatus")

Благодаря

+0

Вы не одиноки, но я думаю, что он стал ближе: HTTPS : //groups.google.com/forum/#! topic/reactivemongo/pj_ztgZfazo –

ответ

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

См. http://reactivemongo.org/releases/0.12/api/index.html#[email protected](implicitec:scala. concurrent.ExecutionContext): scala.concurrent.Future [reactivemongo.api.commands.ServerStatusResult] – cchantep