There are two ways to delete collections. The first is to call dropCollection(name)
on the Db
object. The second is to call the drop()
method on the Collection
object; this is sometimes more convenient, such as when you are iterating through a list of Collection
objects.
The following are the two methods:
var myDB = db.db("myDB ");
myDB.dropCollection("collectionA", function(err, results){ });
// or
myDB.collection("collectionB", function(err, collB){
collB.drop();
});