0 votes
1 view
ago in Web Technology by (28.7k 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
ago by (63.1k points)

You can simply remove the content with the help of the following syntax :

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

   console.log('collection removed') 

});

But there is a process to access the mongodb native javascript driver, which can be used for your situation:

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
2 answers
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...