db.isMaster() in mongoDB

isMaster()

This method returns a document that describes the role of the mongod instance.

If the mongod is a member of a replica set, then the is master and secondary fields report if the instance is the primary or if it is a secondary member of the replica set.

Syntax:

db.isMaster()


Example

MongoDB

db.isMaster()

Output:

{
    "ismaster" : true,
    "topologyVersion" : {
            "processId" : ObjectId("62b40861b169ffdaf4e629c3"),
            "counter" : NumberLong(0)
    },
    "maxBsonObjectSize" : 16777216,
    "maxMessageSizeBytes" : 48000000,
    "maxWriteBatchSize" : 100000,
    "localTime" : ISODate("2022-06-26T06:35:18.391Z"),
    "logicalSessionTimeoutMinutes" : 30,
    "connectionId" : 10,
    "minWireVersion" : 0,
    "maxWireVersion" : 13,
    "readOnly" : false,
    "ok" : 1
}



No comments:

Post a Comment