Class: MongoClient

MongoClient(URI)

MongoDB Driver Starting Class representing a connection to MongoDB Handles any required conneciton pooling and shoudl be created only once and persisted. Will not actually connect until the first information is needed from the server and will automatically manage failover if a server is unavailable.

Constructor

new MongoClient(URI)

Constructor - takes a MongoDB URI Supported URI Format is mongodb+srv://USERNAME:PASSWORD@... The part after ... should be a DNS name and options but is ignored in the simulato. In the simulator you can make up a unique username and password for yourself, minimum 6 characters for each.
Parameters:
Name Type Description
URI string MongoDB Connection Details

Methods

getDatabase(dbName)

Parameters:
Name Type Description
dbName String
Returns:
a MongoDatabase Object representing a database you want to work with

(async) hello()

Requests information about the connected cluster
Returns:
server status information

(async) listDatabaseNames()

Lists databases that exist on the server
Returns:
Array of database names as strings