Question

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.

Was it helpful?

Solution

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);
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top