How to get mongodb version from mongoose
You can use the native mongo driver's Admin#buildInfo
method for that via your Mongoose connection:
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test', function(err){
var admin = new mongoose.mongo.Admin(mongoose.connection.db);
admin.buildInfo(function (err, info) {
console.log(info.version);
});
});
You can query the buildInfo
directly from your Mongoose connection.
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test', function(err) {
mongoose.db.command({ buildInfo: 1 }, function (err, info) {
console.log(info.version);
});
});
https://docs.mongodb.com/manual/reference/command/buildInfo/#dbcmd.buildInfo