如何通过mongojs知道mongodb的版本

dburl = "mongodb://127.0.0.1:27017/demo"; db = require('mongojs').connect(dburl); console.log(db.version); 

我想知道使用mongojs的mongodb版本。

尝试这个:

 db.executeDbCommand({ buildInfo : 1 }, function(err, buildinfo) { console.log('V', buildinfo.documents[0].version); }); 

编辑 :使用command()较短的版本:

 db.command({ buildInfo : 1 }, function(err, buildinfo) { console.log('V', buildinfo.version); }); 

要获取您可以执行的命令列表:

 db.command({ listCommands : 1 }, function(err, response) { console.log(response.commands); });