MongoDB: db.isMaster() method
db.isMaster
The db.isMaster() method is used to return a document that reports the state of the replica set. If the mongod is a member of a replica set, then the ismaster 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() method
db.isMaster();
Output:
> db.isMaster(); { "ismaster" : true, "maxBsonObjectSize" : 16777216, "maxMessageSizeBytes" : 48000000, "maxWriteBatchSize" : 1000, "localTime" : ISODate("2016-01-11T11:44:00.610Z"), "maxWireVersion" : 2, "minWireVersion" : 0, "ok" : 1 }
Retrieve the restaurants data from here
Previous:
db.hostInfo() method
Next:
db.listCommands() method
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/mongodb/shell-methods/database/db-isMaster.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics