mongo: drop collection using the terminal
Straight from the manual page, use the --drop
option:
--drop
Modifies the import process so that the target instance drops every collection before importing the collection from the input.
So you can remove the collection you are importing into and start new.
mongoimport -d myDB -c myCollection --drop --file file.json
Call the db.collection.drop()
method on a collection to drop it from the database.
In bash use mongo <dbname> --eval "db.<collectionName>.drop()"