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}); }
See this code in the driver for an implementation.
source share