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

I want to know mongodb version using mongojs.

有帮助吗?

解决方案

Try this:

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

EDIT: shorter version using command():

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

To get a list of commands that you can execute:

db.command({ listCommands : 1 }, function(err, response) {
  console.log(response.commands);
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top