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 usernamestring The username.
passwordstring The password.
optionsobject null optional Optional settings.
Name Type Default Description wnumber | string null optional The write concern.
wtimeoutnumber null optional The write concern timeout.
jboolean false optional Specify a journal write concern.
fsyncboolean false optional Specify a file sync write concern.
customDataobject null optional Custom data associated with the user (only Mongodb 2.6 or higher)
rolesArray.<object> null optional Roles associated with the created user (only Mongodb 2.6 or higher)
sessionClientSession optional optional session to use for this operation
callbackAdmin~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 clientName Type Description optionsObject optional optional parameters for this operation
Name Type Description sessionClientSession optional optional session to use for this operation
callbackAdmin~resultCallback optional The command result callback
Returns:
Promise if no callback passed
-
command(command, options, callback){Promise}
-
Execute a command
Name Type Default Description commandobject The command hash
optionsobject null optional Optional settings.
Name Type Default Description readPreferenceReadPreference | string null optional The preferred read preference (ReadPreference.PRIMARY, ReadPreference.PRIMARY_PREFERRED, ReadPreference.SECONDARY, ReadPreference.SECONDARY_PREFERRED, ReadPreference.NEAREST).
maxTimeMSnumber null optional Number of milliseconds to wait before aborting the query.
callbackAdmin~resultCallback optional The command result callback
Returns:
Promise if no callback passed
-
listDatabases(options, callback){Promise}
-
List the available databases
Name Type Default Description optionsobject null optional Optional settings.
Name Type Default Description nameOnlyboolean false optional Whether the command should return only db names, or names and size info.
sessionClientSession optional optional session to use for this operation
callbackAdmin~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 optionsObject optional optional parameters for this operation
Name Type Description sessionClientSession optional optional session to use for this operation
callbackAdmin~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 usernamestring The username.
optionsobject null optional Optional settings.
Name Type Default Description wnumber | string null optional The write concern.
wtimeoutnumber null optional The write concern timeout.
jboolean false optional Specify a journal write concern.
fsyncboolean false optional Specify a file sync write concern.
sessionClientSession optional optional session to use for this operation
callbackAdmin~resultCallback optional The command result callback
Returns:
Promise if no callback passed
-
replSetGetStatus(options, callback){Promise}
-
Get ReplicaSet status
Name Type Description optionsObject optional optional parameters for this operation
Name Type Description sessionClientSession optional optional session to use for this operation
callbackAdmin~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 clientName Type Description optionsObject optional optional parameters for this operation
Name Type Description sessionClientSession optional optional session to use for this operation
callbackAdmin~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 optionsObject optional optional parameters for this operation
Name Type Description sessionClientSession optional optional session to use for this operation
callbackAdmin~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 collectionNamestring The name of the collection to validate.
optionsobject null optional Optional settings.
Name Type Description sessionClientSession optional optional session to use for this operation
callbackAdmin~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 errorMongoError An error instance representing the error during the execution.
resultobject The result object if the command was executed successfully.