To drop a database with Mongoose and JavaScript, we use the Mongo native driver’s drop
method.
For instance, we write
mongoose.connection.collections["collectionName"].drop((err) => {
console.log("collection dropped");
});
to get the Mongo collection with collections
.
And we call drop
with a callback that’s called when there’s an error to drop the collectionName
collection.