makeDBuri {Proc4} | R Documentation |
This function formats the universal record indicator (URI) for connecting to a Mongo database. It is mostly a utility function for formatting the string.
makeDBuri(username = "", password = "", host = "localhost", port = "", protocol="mongodb")
username |
The name of the database user (login credential), or an empty string if no username is required. |
password |
The name of the database password (login credential), or an empty string if no password is required. |
host |
The name or IP address of the system hosting the database. |
port |
The port to be used for connections. Note that the port for a default configuration of mongo is 27018. This can be left blank to use the default port. |
protocol |
A character scalar giving the protocol to use when connecting, e.g., “mongodb”. |
A character string giving the database URI which can be passed to the
mongo
function to create a database
collection handle.
Note that the password is stored in clear text, so appropriate care should be taken with the result of this function.
Russell Almond
This is an input argument to a number of other classes which use mongo connections.
stopifnot(makeDBuri()=="mongodb://localhost") stopifnot(makeDBuri(user="admin",password="secret")== "mongodb://admin:secret@localhost") ## No password stopifnot(makeDBuri(user="admin")== "mongodb://admin@localhost") stopifnot(makeDBuri(host="example.com",port=12345) == "mongodb://example.com:12345")