Deleting Collections

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();
});

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.121.209