0

How can I run db.runCommand("serverStatus") in scala 2.11.4? I'm using play2-reactivemongo 0.10.5.0.akka23 ? The db.command takes RawCommand in reactiveMongo which in turn is a BSONDocument. How to run commands of database like db.serverStatus() or db.printShardingStatus()

Thanks

  • You are not alone, but I think he got closer: https://groups.google.com/forum/#!topic/reactivemongo/pj_ztgZfazo – Ed Staub Apr 02 '15 at 02:00

1 Answers1

1

Found the solution:

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
    See http://reactivemongo.org/releases/0.12/api/index.html#reactivemongo.api.DefaultDB@serverStatus(implicitec:scala.concurrent.ExecutionContext):scala.concurrent.Future[reactivemongo.api.commands.ServerStatusResult] – cchantep Oct 22 '16 at 20:03