Mongo.getURI()
On this page
Definition
Mongo.getURI()
Returns: The connection string for the current active connection. See the Connection Strings for more information.
Syntax
The command takes the following form:
db.getMongo().getURI()
You can use this method to return a URI string for a connection, which
you can then use to create a new Mongo()
instance:
new Mongo(db.getMongo().getURI())
Example
To return the current connection string, enter the following:
db.getMongo().getURI()
mongodb://127.0.0.1:27019/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.1.4