Learn R Programming

rmongodb (version 1.8.0)

mongo.is.master: Determine if a mongo connection object is connected to a master

Description

Determine if a mongo connection object is connected to a master. Normally, this is only used with replsets to see if we are currently connected to the master of the replset. However, when connected to a singleton, this function reports TRUE also.

Usage

mongo.is.master(mongo)

Arguments

mongo
(mongo) a mongo connection object.

Value

(logical) TRUE if the server reports that it is a master; otherwise, FALSE.

See Also

mongo.create, mongo.

Examples

Run this code
## Not run: 
# mongo <- mongo.create(c("127.0.0.1", "192.168.0.3"), name="Accounts")
# if (mongo.is.connected(mongo)) {
#     print("isMaster")
#     print(if (mongo.is.master(mongo)) "Yes" else "No")
# }
# ## End(Not run)

Run the code above in your browser using DataLab