Вопрос

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