lib/operations/db_ops.js
function executeAuthRemoveUserCommand(db, username, options, callback) {
  if (typeof options === 'function') (callback = options), (options = {});
  options = options || {};

  // Did the user destroy the topology
  if (db.serverConfig && db.serverConfig.isDestroyed())
    return callback(new MongoError('topology was destroyed'));
  // Get the error options
  const commandOptions = { writeCommand: true };
  if (options['dbName']) commandOptions.dbName = options['dbName'];

  // Get additional values
  const maxTimeMS = typeof options.maxTimeMS === 'number' ? options.maxTimeMS : null;

  // Add maxTimeMS to options if set
  if (maxTimeMS != null) commandOptions.maxTimeMS = maxTimeMS;

  // Build the command to execute
  let command = {
    dropUser: username
  };

  // Apply write concern to command
  command = applyWriteConcern(command, { db }, options);

  // Force write using primary
  commandOptions.readPreference = ReadPreference.primary;

  // Execute the command
  executeCommand(db, command, commandOptions, (err, result) => {
    if (err && !err.ok && err.code === undefined) return handleCallback(callback, { code: -5000 });
    if (err) return handleCallback(callback, err, null);
    handleCallback(callback, null, result.ok ? true : false);
  });
}
function executeAuthRemoveUserCommand(db, username, options, callback) {
  if (typeof options === 'function') (callback = options), (options = {});
  options = options || {};

  // Did the user destroy the topology
  if (db.serverConfig && db.serverConfig.isDestroyed())
    return callback(new MongoError('topology was destroyed'));
  // Get the error options
  const commandOptions = { writeCommand: true };
  if (options['dbName']) commandOptions.dbName = options['dbName'];

  // Get additional values
  const maxTimeMS = typeof options.maxTimeMS === 'number' ? options.maxTimeMS : null;

  // Add maxTimeMS to options if set
  if (maxTimeMS != null) commandOptions.maxTimeMS = maxTimeMS;

  // Build the command to execute
  let command = {
    dropUser: username
  };

  // Apply write concern to command
  command = applyWriteConcern(command, { db }, options);

  // Force write using primary
  commandOptions.readPreference = ReadPreference.primary;

  // Execute the command
  executeCommand(db, command, commandOptions, (err, result) => {
    if (err && !err.ok && err.code === undefined) return handleCallback(callback, { code: -5000 });
    if (err) return handleCallback(callback, err, null);
    handleCallback(callback, null, result.ok ? true : false);
  });
}
function executeAuthRemoveUserCommand ( db , username , options , callback ) { if ( typeof options === 'function' ) ( callback = options ) , ( options = { } ) ; options = options || { } ; // Did the user destroy the topology if ( db . serverConfig && db . serverConfig . isDestroyed ( ) ) return callback ( new MongoError ( 'topology was destroyed' ) ) ; // Get the error options const commandOptions = { writeCommand : true } ; if ( options [ 'dbName' ] ) commandOptions . dbName = options [ 'dbName' ] ; // Get additional values const maxTimeMS = typeof options . maxTimeMS === 'number' ? options . maxTimeMS : null ; // Add maxTimeMS to options if set if ( maxTimeMS != null ) commandOptions . maxTimeMS = maxTimeMS ; // Build the command to execute let command = { dropUser : username } ; // Apply write concern to command command = applyWriteConcern ( command , { db } , options ) ; // Force write using primary commandOptions . readPreference = ReadPreference . primary ; // Execute the command executeCommand ( db , command , commandOptions , ( err , result ) => { if ( err && ! err . ok && err . code === undefined ) return handleCallback ( callback , { code : - 5000 } ) ; if ( err ) return handleCallback ( callback , err , null ) ; handleCallback ( callback , null , result . ok ? true : false ) ; } ) ; }
Run the dropUser command.

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