June 2014
Intermediate to advanced
696 pages
38h 52m
English
Using a MongoClient object to connect to MongoDB involves creating an instance of the client, opening a connection to the database, authenticating to the database if necessary, and then handling logout and closure as needed. This method has the advantage of allowing you to manipulate each step of the connection and authentication.
To connect to MongoDB via a MongoClient object, you need to first create an instance of the MongoClient object. The constructor for the MongoClient class takes a Server object as the first parameter and an object specifying the database connection options as the second parameter, as shown below:
MongoClient(Server, options)
Table 13.3 lists the most important database connection ...
Read now
Unlock full access