Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

Is it possible to remove a collection or entire db using mongoose.js?

2 Answers

0 votes
by (106k points)

To remove collection or DB where the native Db object is accessible via mongoose.connection.db, and that object provides dropCollection and dropDatabase methods.

mongoose.connection.db.dropCollection('foo', function(err, result) {...}); 

mongoose.connection.db.dropDatabase(function(err, result) {...});

0 votes
by (108k points)

This can now be done in Mongoose.

MyModel.collection.drop();

Browse Categories

...