How to get mongodb version from mongoose

Simple, with mongo cli:

db.version () 

How can I do the same with mongoose? How to send a custom command?

+4
source share
1 answer

You can use the mongo Admin#buildInfo native driver to do this through 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); }); }); 
+7
source

All Articles