Reputation: 11356
This seems like a really easy thing and I wonder if this is my least clever question here on Stack Overflow.
I would like to figure out the version of the MongoDB server that node-mongodb-native
is connected to.
However, I cannot seem to find anything regarding this using google. It's not the same as require('mongodb').version
; this holds the node module verion.
Upvotes: 5
Views: 3119
Reputation: 51990
You have to use the serverStatus
database command to retrieve the version of the mongod
or mongos
instance you're connected to.
The native node.js driver provides the Admin.serverStatus
for that purpose:
var MongoClient = require('mongodb').MongoClient
var url = 'mongodb://localhost:27017/test'
var conn = MongoClient.connect(url, function(err, db) {
var adminDb = db.admin();
adminDb.serverStatus(function(err, info) {
console.log(info.version);
})
})
Displaying on my system:
3.0.2
Upvotes: 7