Class: Admin

Admin

new Admin(){Admin}

Create a new Admin instance (INTERNAL TYPE, do not instantiate directly)

Returns:
collection instance.

Methods

addUser(username, password, options, callback){Promise}

Add a user to the database.

Name Type Default Description
username string

The username.

password string

The password.

options object null optional

Optional settings.

Name Type Default Description
w number | string null optional

The write concern.

wtimeout number null optional

The write concern timeout.

j boolean false optional

Specify a journal write concern.

fsync boolean false optional

Specify a file sync write concern.

customData object null optional

Custom data associated with the user (only Mongodb 2.6 or higher)

roles Array.<object> null optional

Roles associated with the created user (only Mongodb 2.6 or higher)

session ClientSession optional

optional session to use for this operation

callback Admin~resultCallback optional

The command result callback

Returns:
Promise if no callback passed

buildInfo(options, callback){Promise}

Retrieve the server information for the current
instance of the db client

Name Type Description
options Object optional

optional parameters for this operation

Name Type Description
session ClientSession optional

optional session to use for this operation

callback Admin~resultCallback optional

The command result callback

Returns:
Promise if no callback passed

command(command, options, callback){Promise}

Execute a command

Name Type Default Description
command object

The command hash

options object null optional

Optional settings.

Name Type Default Description
readPreference ReadPreference | string null optional

The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).

maxTimeMS number null optional

Number of milliseconds to wait before aborting the query.

callback Admin~resultCallback optional

The command result callback

Returns:
Promise if no callback passed

listDatabases(options, callback){Promise}

List the available databases

Name Type Default Description
options object null optional

Optional settings.

Name Type Default Description
nameOnly boolean false optional

Whether the command should return only db names, or names and size info.

session ClientSession optional

optional session to use for this operation

callback Admin~resultCallback optional

The command result callback.

Returns:
Promise if no callback passed

ping(options, callback){Promise}

Ping the MongoDB server and retrieve results

Name Type Description
options Object optional

optional parameters for this operation

Name Type Description
session ClientSession optional

optional session to use for this operation

callback Admin~resultCallback optional

The command result callback

Returns:
Promise if no callback passed

removeUser(username, options, callback){Promise}

Remove a user from a database

Name Type Default Description
username string

The username.

options object null optional

Optional settings.

Name Type Default Description
w number | string null optional

The write concern.

wtimeout number null optional

The write concern timeout.

j boolean false optional

Specify a journal write concern.

fsync boolean false optional

Specify a file sync write concern.

session ClientSession optional

optional session to use for this operation

callback Admin~resultCallback optional

The command result callback

Returns:
Promise if no callback passed

replSetGetStatus(options, callback){Promise}

Get ReplicaSet status

Name Type Description
options Object optional

optional parameters for this operation

Name Type Description
session ClientSession optional

optional session to use for this operation

callback Admin~resultCallback optional

The command result callback.

Returns:
Promise if no callback passed

serverInfo(options, callback){Promise}

Retrieve the server information for the current
instance of the db client

Name Type Description
options Object optional

optional parameters for this operation

Name Type Description
session ClientSession optional

optional session to use for this operation

callback Admin~resultCallback optional

The command result callback

Returns:
Promise if no callback passed

serverStatus(options, callback){Promise}

Retrieve this db's server status.

Name Type Description
options Object optional

optional parameters for this operation

Name Type Description
session ClientSession optional

optional session to use for this operation

callback Admin~resultCallback optional

The command result callback

Returns:
Promise if no callback passed

validateCollection(collectionName, options, callback){Promise}

Validate an existing collection

Name Type Default Description
collectionName string

The name of the collection to validate.

options object null optional

Optional settings.

Name Type Description
session ClientSession optional

optional session to use for this operation

callback Admin~resultCallback optional

The command result callback.

Returns:
Promise if no callback passed

Type Definitions

resultCallback(error, result)

The callback format for results

Name Type Description
error MongoError

An error instance representing the error during the execution.

result object

The result object if the command was executed successfully.