lib/operations/db_ops.js
function removeUser(db, username, options, callback) {
  let Db = loadDb();

  // Attempt to execute command
  executeAuthRemoveUserCommand(db, username, options, (err, result) => {
    if (err && err.code === -5000) {
      const finalOptions = applyWriteConcern(Object.assign({}, options), { db }, options);
      // If we have another db set
      const db = options.dbName ? new Db(options.dbName, db.s.topology, db.s.options) : db;

      // Fetch a user collection
      const collection = db.collection(CONSTANTS.SYSTEM_USER_COLLECTION);

      // Locate the user
      findOne(collection, { user: username }, finalOptions, (err, user) => {
        if (user == null) return handleCallback(callback, err, false);
        remove(collection, { user: username }, finalOptions, err => {
          handleCallback(callback, err, true);
        });
      });

      return;
    }

    if (err) return handleCallback(callback, err);
    handleCallback(callback, err, result);
  });
}
function removeUser(db, username, options, callback) {
  let Db = loadDb();

  // Attempt to execute command
  executeAuthRemoveUserCommand(db, username, options, (err, result) => {
    if (err && err.code === -5000) {
      const finalOptions = applyWriteConcern(Object.assign({}, options), { db }, options);
      // If we have another db set
      const db = options.dbName ? new Db(options.dbName, db.s.topology, db.s.options) : db;

      // Fetch a user collection
      const collection = db.collection(CONSTANTS.SYSTEM_USER_COLLECTION);

      // Locate the user
      findOne(collection, { user: username }, finalOptions, (err, user) => {
        if (user == null) return handleCallback(callback, err, false);
        remove(collection, { user: username }, finalOptions, err => {
          handleCallback(callback, err, true);
        });
      });

      return;
    }

    if (err) return handleCallback(callback, err);
    handleCallback(callback, err, result);
  });
}
function removeUser ( db , username , options , callback ) { let Db = loadDb ( ) ; // Attempt to execute command executeAuthRemoveUserCommand ( db , username , options , ( err , result ) => { if ( err && err . code === - 5000 ) { const finalOptions = applyWriteConcern ( Object . assign ( { } , options ) , { db } , options ) ; // If we have another db set const db = options . dbName ? new Db ( options . dbName , db . s . topology , db . s . options ) : db ; // Fetch a user collection const collection = db . collection ( CONSTANTS . SYSTEM_USER_COLLECTION ) ; // Locate the user findOne ( collection , { user : username } , finalOptions , ( err , user ) => { if ( user == null ) return handleCallback ( callback , err , false ) ; remove ( collection , { user : username } , finalOptions , err => { handleCallback ( callback , err , true ) ; } ) ; } ) ; return ; } if ( err ) return handleCallback ( callback , err ) ; handleCallback ( callback , err , result ) ; } ) ; }
Remove a user from a database

@method
@param {Db} db The Db instance on which to remove the user.
@param {string} username The username.
@param {object} [options] Optional settings. See Db.prototype.removeUser for a list of options.
@param {Db~resultCallback} [callback] The command result callback
Remove a user from a database