About the connection string
The connection string—dbURI
in our examples—can use any of the options from the MongoDB connection string. We're not going to cover them all here, but here are a couple of common options.
Setting the port
The default port is 27017. If you wanted to specify a different port, say 27018, you would do so using the following code snippet:
var dbURI = 'mongodb://localhost:27018/mydatabase';
Specifying a database user
If you want to access the database as a particular user, you can add the username and password in front of the hostname.
var dbURI = 'mongodb://username:password@localhost/mydatabase';