Reputation: 61
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.
Upvotes: 1
Views: 371
Reputation: 203286
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);
});
Upvotes: 3