Running db.repairDatabase () from mongodb-native in node.js

I can run db.repairDatabase () from the mongodb shell, but I cannot find an example to run the same command from the node.js application using the mongodb native module. How to start "repairDatabase" using executeDbCommand method?

+4
source share
2 answers
db.command({repairDatabase:1}, function(err, result) { }); 
+7
source

If you want to see what mongo javascript shell does, just remove the bracket and it will show you the base 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 an implementation.

+2
source

Source: https://habr.com/ru/post/1397330/


All Articles