import type { Document } from './bson'; import type { Db } from './db'; import { AddUserOptions } from './operations/add_user'; import type { CommandOperationOptions } from './operations/command'; import { ListDatabasesOptions, ListDatabasesResult } from './operations/list_databases'; import { RemoveUserOptions } from './operations/remove_user'; import { RunCommandOptions } from './operations/run_command'; import { ValidateCollectionOptions } from './operations/validate_collection'; import type { Callback } from './utils'; /** @internal */ export interface AdminPrivate { db: Db; } /** * The **Admin** class is an internal class that allows convenient access to * the admin functionality and commands for MongoDB. * * **ADMIN Cannot directly be instantiated** * @public * * @example * ```js * const MongoClient = require('mongodb').MongoClient; * const test = require('assert'); * // Connection url * const url = 'mongodb://localhost:27017'; * // Database Name * const dbName = 'test'; * * // Connect using MongoClient * MongoClient.connect(url, function(err, client) { * // Use the admin database for the operation * const adminDb = client.db(dbName).admin(); * * // List all the available databases * adminDb.listDatabases(function(err, dbs) { * expect(err).to.not.exist; * test.ok(dbs.databases.length > 0); * client.close(); * }); * }); * ``` */ export declare class Admin { /** @internal */ s: AdminPrivate; /** * Create a new Admin instance * @internal */ constructor(db: Db); /** * Execute a command * * @param command - The command to execute * @param options - Optional settings for the command * @param callback - An optional callback, a Promise will be returned if none is provided */ command(command: Document): Promise; command(command: Document, callback: Callback): void; command(command: Document, options: RunCommandOptions): Promise; command(command: Document, options: RunCommandOptions, callback: Callback): void; /** * Retrieve the server build information * * @param options - Optional settings for the command * @param callback - An optional callback, a Promise will be returned if none is provided */ buildInfo(): Promise; buildInfo(callback: Callback): void; buildInfo(options: CommandOperationOptions): Promise; buildInfo(options: CommandOperationOptions, callback: Callback): void; /** * Retrieve the server build information * * @param options - Optional settings for the command * @param callback - An optional callback, a Promise will be returned if none is provided */ serverInfo(): Promise; serverInfo(callback: Callback): void; serverInfo(options: CommandOperationOptions): Promise; serverInfo(options: CommandOperationOptions, callback: Callback): void; /** * Retrieve this db's server status. * * @param options - Optional settings for the command * @param callback - An optional callback, a Promise will be returned if none is provided */ serverStatus(): Promise; serverStatus(callback: Callback): void; serverStatus(options: CommandOperationOptions): Promise; serverStatus(options: CommandOperationOptions, callback: Callback): void; /** * Ping the MongoDB server and retrieve results * * @param options - Optional settings for the command * @param callback - An optional callback, a Promise will be returned if none is provided */ ping(): Promise; ping(callback: Callback): void; ping(options: CommandOperationOptions): Promise; ping(options: CommandOperationOptions, callback: Callback): void; /** * Add a user to the database * * @param username - The username for the new user * @param password - An optional password for the new user * @param options - Optional settings for the command * @param callback - An optional callback, a Promise will be returned if none is provided */ addUser(username: string): Promise; addUser(username: string, callback: Callback): void; addUser(username: string, password: string): Promise; addUser(username: string, password: string, callback: Callback): void; addUser(username: string, options: AddUserOptions): Promise; addUser(username: string, options: AddUserOptions, callback: Callback): void; addUser(username: string, password: string, options: AddUserOptions): Promise; addUser(username: string, password: string, options: AddUserOptions, callback: Callback): void; /** * Remove a user from a database * * @param username - The username to remove * @param options - Optional settings for the command * @param callback - An optional callback, a Promise will be returned if none is provided */ removeUser(username: string): Promise; removeUser(username: string, callback: Callback): void; removeUser(username: string, options: RemoveUserOptions): Promise; removeUser(username: string, options: RemoveUserOptions, callback: Callback): void; /** * Validate an existing collection * * @param collectionName - The name of the collection to validate. * @param options - Optional settings for the command * @param callback - An optional callback, a Promise will be returned if none is provided */ validateCollection(collectionName: string): Promise; validateCollection(collectionName: string, callback: Callback): void; validateCollection(collectionName: string, options: ValidateCollectionOptions): Promise; validateCollection(collectionName: string, options: ValidateCollectionOptions, callback: Callback): void; /** * List the available databases * * @param options - Optional settings for the command * @param callback - An optional callback, a Promise will be returned if none is provided */ listDatabases(): Promise; listDatabases(callback: Callback): void; listDatabases(options: ListDatabasesOptions): Promise; listDatabases(options: ListDatabasesOptions, callback: Callback): void; /** * Get ReplicaSet status * * @param options - Optional settings for the command * @param callback - An optional callback, a Promise will be returned if none is provided */ replSetGetStatus(): Promise; replSetGetStatus(callback: Callback): void; replSetGetStatus(options: CommandOperationOptions): Promise; replSetGetStatus(options: CommandOperationOptions, callback: Callback): void; } //# sourceMappingURL=admin.d.ts.map