Understanding the Admin Object

You use the Admin object to perform certain administrative functions on a MongoDB database. The Admin object represents a connection specifically to the admin database and provides functionality not included in the Db object.

You can get the Admin object by using the admin() method on an instance of the Db object or by passing a Db object into the constructor. For example, both of the following work fine:

var adminDb = db.admin()
var adminDb = new Admin(db)

Table 13.6 lists the important methods you can call from an Admin object. These methods allow you to ping the MongoDB server, add and remove users from the admin database, list databases, etc.

Image

Table 13.6 Methods on the Admin object

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.168.46