2015-04-01 72 views
0

如何在scala 2.11.4中運行db.runCommand(「serverStatus」)?我正在使用play2-reactivemongo 0.10.5.0.akka23? db.command在reactiveMongo中使用RawCommand,這反過來是一個BSONDocument。如何運行像db.serverStatus()或db.printShardingStatus()數據庫的命令Scala + ReactiveMongo db.runCommand(「serverStatus」)

感謝

+0

你並不孤單,但我認爲他走近:HTTPS ://groups.google.com/forum/#!topic/reactivemongo/pj_ztgZfazo – 2015-04-02 02:00:45

回答

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 2016-10-22 20:03:47

相關問題