Simple, with the mongo cli:
db.version ()
How can I do the same with mongoose? How can I send a custom command?
Try this one, it will give you the verion of both MongoDB and Mongoose
async function run() {
var admin = new mongoose.mongo.Admin(mongoose.connection.db);
admin.buildInfo(function (err, info) {
console.log(`mongodb: ${info.version}`);
console.log(`mongoose: ${mongoose.version}`);
});
}
mongoose.connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true
})
.then(() => {
console.log('MongoDB connected');
run();
})
.catch(error => {
console.log(error);
});