Commits

Liam Staskawicz committed 2fb6298

* a couple more DB commands

Comments (0)

Files changed (2)

       throw MongoOpErr("dropDatabase failed: ${res}")
   }
   
+  **
+  ** List all databases known on the DB server
+  ** Each item returned is a Map with the Str keys: "name", "sizeOnDisk" and "empty"
+  ** Note - you must be authenticated for this to succeed
+  **
+  List listDatabases()
+  {
+    res := command(["listDatabases": 1], true)
+    if(!cmdOk(res))
+      throw MongoOpErr("listDatabases failed: ${res}")
+    return res["databases"]
+  }
+  
+  **
+  ** Returns status info about the DB server - uptime, lock info, memory info
+  **
+  Map serverStatus()
+  {
+    // weird...doesn't return an "ok" in the response...just return it directly
+    return command(["serverStatus": 1])
+  }
+  
+  **
+  ** Repair/compact this DB.
+  **
+  Void repair(Bool preserveClonedFilesOnFailure, Bool backupOriginalFiles)
+  {
+    c := Str:Obj [:] { ordered = true }
+    c["repairDatabase"] = 1
+    c["preserveClonedFilesOnFailure"] = preserveClonedFilesOnFailure
+    c["backupOriginalFiles"] = backupOriginalFiles
+    res := command(c)
+    if(!cmdOk(res))
+      throw MongoOpErr("repairDatabase error - $res")
+  }
+  
 }
     verifyFalse(db.collectionNames().contains(fullname))
   }
   
+  Void testServerStatus()
+  {
+    ss := db.serverStatus
+    verify(ss.keys.containsAll(["uptime", "globalLock", "mem"]))
+  }
+  
+  Void testListDatabases()
+  {
+    db.listDatabases.each |Map v, i| {
+      verify(v.keys.containsAll(["name", "sizeOnDisk", "empty"]))
+    }
+  }
+  
+  Void testRepair()
+  {
+    db.repair(true, true) // just run it...make sure no Errs are thrown
+  }
+  
 }
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.