I would like to run db.printReplicationInfo()
from a C # driver.
As far as I can tell, I can run the commands listed here using MongoDatabase.RunCommandAsync
. For this, I have a code that looks like this:
var command = new BsonDocumentCommand<BsonDocument>(new BsonDocument
{
{"replSetGetStatus", 1}
});
var result = BsonSerializer.Deserialize<ReplicaSetStatus>(
client.GetDatabase(ADMIN_DATABASE).RunCommandAsync(command).Result);
This allows me to run the command and deserialize the response in the object we created ReplicaSetStatus
. (the client is an instance of MongoClient).
My question is: can I use RunCommandAsync
to execute a type operation db.printReplicationInfo()
? What does the team look like?
If not, what is the way to perform such an operation from C #?
Someone seemed to have a similar question , but he did not get any useful answers.
Thanks!
source
share