Docs Menu
Docs Home
/
MongoDB Manual
/ / /

Mongo.getURI()

On this page

  • Definition
  • Syntax
  • Example
Mongo.getURI()
Returns:The connection string for the current active connection.

See the Connection Strings for more information.

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())

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

Back

Mongo.getReadPrefTagSet