Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get mongodb version from mongoose

Simple, with the mongo cli:

db.version ()

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

like image 512
Gabriel Llamas Avatar asked Mar 09 '13 13:03

Gabriel Llamas


1 Answers

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);
  });
});
like image 121
JohnnyHK Avatar answered Sep 18 '22 21:09

JohnnyHK