- Reference >
- Database Commands >
- isMaster
isMaster¶
-
isMaster
¶ The
isMaster
command provides a basic overview of the current replication configuration. MongoDB drivers and clients use this command to determine what kind of member they’re connected to and to discover additional members of a replica set. Thedb.isMaster()
method provides a wrapper around this database command.The command takes the following form:
This command returns a document containing the following fields:
-
isMaster.
setname
¶ The name of the current replica set, if applicable.
-
isMaster.
ismaster
¶ A boolean value that reports when this node is writable. If
true
, then the current node is either a primary in a replica set, a master in a master-slave configuration, or a standalonemongod
.
-
isMaster.
secondary
¶ A boolean value that, when
true
, indicates that the current member is a secondary member of a replica set.
-
isMaster.
hosts
¶ An array of strings in the format of “
[hostname]:[port]
” listing all members of the replica set that are not “hidden”.
-
isMaster.
arbiter
¶ An array of strings in the format of “
[hostname]:[port]
” listing all members of the replica set that are arbitersOnly appears in the
isMaster
response for replica sets that have arbiter members.
-
isMaster.
arbiterOnly
¶ A boolean value that, when
true
indicates that the current instance is an arbiter.arbiterOnly
only appears in theisMaster
response from arbiters.
-
isMaster.
primary
¶ The
[hostname]:[port]
for the current replica set primary, if applicable.
-
isMaster.
me
¶ The
[hostname]:[port]
of the node responding to this command.
-