Friday 19 May 2017

How to get slave status of mongodb using nodejs?

I want to get slavestatus of mongodb server using node js. Here is the code.

var Db = require('mongodb').Db, Server = require('mongodb').Server;
        var db = new Db('admin', new Server(conf.host, conf.port));
        db.open(function(err, db1) {
            var adminDb = db1.admin();
             adminDb.command({ "status": 1 },function(err,result) {
                  console.log("output="+result);
            });
    });

But i am getting error.

error=MongoError: no such command: 'status', bad cmd: '{ status: 1 }'



via selvan

No comments:

Post a Comment