Możesz użyć RunCommand
metoda do pobrania db.stats()
wyniki takie:
var command = new CommandDocument {{ "dbStats", 1}, {"scale", 1}};
var result = db.RunCommand<BsonDocument>(command);
Wynik będzie taki:
{
"db" : "Test",
"collections" : 7,
"objects" : 32,
"avgObjSize" : 94.0,
"dataSize" : 3008,
"storageSize" : 57344,
"numExtents" : 7,
"indexes" : 5,
"indexSize" : 40880,
"fileSize" : 67108864,
"nsSizeMB" : 16,
"dataFileVersion" : {
"major" : 4,
"minor" : 5
},
"extentFreeList" : {
"num" : 0,
"totalSize" : 0
},
"ok" : 1.0
}
I dla db.getCollectionNames()
; sposobem jest użycie tego polecenia:
var command = new CommandDocument { { "listCollections", 1 }, { "scale", 1 } };
var result = db.RunCommand<BsonDocument>(command);
// and to clear extra details
var colNames = result["cursor"]["firstBatch"].AsBsonArray.Values.Select(c => c["name"]);