0 votes
1 view
in Web Technology by (48.4k 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 (104k 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

0 votes
1 answer
+1 vote
2 answers
0 votes
2 answers
0 votes
2 answers
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...