Created
November 26, 2019 19:38
-
-
Save jerrymannel/e5fef73c5f172f875ba69fb9af7af826 to your computer and use it in GitHub Desktop.
Find the mongo server version and replica set information from nodejs client.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MongoClient = require('mongodb').MongoClient; | |
const assert = require('assert'); | |
var url = 'mongodb://localhost:27017'; | |
const dbName = 'test'; | |
const client = new MongoClient(url, { useUnifiedTopology: true }); | |
client.connect(function(err) { | |
assert.equal(null, err); | |
console.log("Connected successfully to server"); | |
client.db().executeDbAdminCommand({ buildInfo: 1 }) | |
.then(_d => console.log(`MONGODB server version :: ${_d.version}`)) | |
client.db().executeDbAdminCommand({ replSetGetStatus: 1 }) | |
.then(_d => console.log(`REPLICASET :: ${_d.set}`), | |
_e => console.log(_e)) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment