dropDatabasecommand drops the current database, deleting the associated data files.
The command has the following form:
The command takes the following optional field:
Field Description writeConcern Optional. A document expressing the write concern of the
dropcommand. Omit to use the default write concern.
Starting in versions 3.6, the operation takes an exclusive (X) database lock while dropping the collections in the database but a global lock when dropping the now-empty database.
Changed in version 3.6:
dropDatabase waits until all collections drops in the database have propagated to a majority of the replica set members.
If you drop a database and create a new database with the same name, you must either restart all
mongos instances, or use the
flushRouterConfig command on all
mongos instances before reading or writing to that database. This action ensures that the
mongos instances refresh their metadata cache, including the location of the primary shard for the new database. Otherwise, the
mongos may miss data on reads and may write data to a wrong shard.