Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Admin

The Admin class is an internal class that allows convenient access to the admin functionality and commands for MongoDB.

ADMIN Cannot directly be instantiated

example
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();
  });
});

Hierarchy

  • Admin

Index

Constructors

constructor

Properties

s

internal

Methods

addUser

buildInfo

command

listDatabases

ping

removeUser

replSetGetStatus

serverInfo

serverStatus

validateCollection

Generated using TypeDoc