admin管理员组

文章数量:1394526

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 badges
Add a ment  | 

2 Answers 2

Reset to default 9
db.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.

本文标签: javascriptRunning dbrepairDatabase() from mongodbnative in nodejsStack Overflow