Intellipaat Back

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

I could not find a way to drop the database with Mongoose as I'm preparing a database creation script in Node.js and Mongoose.

1 Answer

0 votes
by (107k points)
edited by

For removing the content refer the following syntax :

Model.remove({}, function(err) { 

   console.log('collection has been removed') 

});

But before removing the content, you have to access the mongodb native javascript driver, refer the following process for accessing the javascript driver:

mongoose.connection.collections['collectionName'].drop( function(err) {

    console.log('collection dropped');

});

Related questions

+1 vote
2 answers
0 votes
2 answers
0 votes
2 answers
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...