且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从猫鼬获取mongodb版本

更新时间:2023-11-26 10:28:10

您可以使用本机mongo驱动程序的

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);
  });
});