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.
Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.