C# equivalent to db.repairDatabase()

Is there a way to call MongoDB's db.repairDatabase() function from the C# driver?

I am able to compact collections:

database.RunCommand(new CommandDocument("compact","collectionname"));

But I don't manage to call repairDatabase.

Answers


In response to your comment that you got an exception with the message "bad option", it turns out that the server is picky about whether you use 1 or true as the value for the repairDatabase field. The following two are equivalent and both fail because the server doesn't like "true" instead of "1":

database.RunCommand("repairDatabase");
database.RunCommnad(new CommandDocument("repairDatabase", true));

but this works:

database.RunCommnad(new CommandDocument("repairDatabase", 1));

You could report a JIRA against the server if this concerns you:

https://jira.mongodb.org/browse/SERVER


The database.RunCommand method is overloaded. It can also take a string that is the name of command, as follows:

database.RunCommand("repairDatabase")

It also returns a CommandResult object.


Need Your Help

Checking for database existence with Phing

php ant phing ant-contrib

I'd like to do something like the following in my Phing build.xml:

Can I listen for events from Notepad++ when making plugin

events plugins notepad++

I can't seem to find info on whether or not this is possible, but I want to know if its possible to have a notepad++ plugin listen for events from the notepad++/scintilla application. If so what are