I can run db.repairDatabase() from the mongodb shell but I can't find an example on running the same mand from node.js app using the mongodb-native module. How can I run "repairDatabase" with executeDbCommand method?
I can run db.repairDatabase() from the mongodb shell but I can't find an example on running the same mand from node.js app using the mongodb-native module. How can I run "repairDatabase" with executeDbCommand method?
Share Improve this question asked Feb 19, 2012 at 22:25 stradastrada 9429 silver badges18 bronze badges2 Answers
Reset to default 9db.mand({repairDatabase:1}, function(err, result) {
});
If you want to see what the mongo javascript shell does, just remove the parenthesis and it will show you the underlying code:
> db.repairDatabase
function () {
return this._dbCommand({repairDatabase:1});
}
//This basically...
>return this.getCollection("$cmd").findOne({repairDatabase:1});
See this code in the driver for the implementation.