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
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join