0 votes
1 view
in Web Technology by (41.4k points)

What is the best way to drop a collection in MongoDB?

I am using the following:

db.collection.drop()

As described in the manual:

db.collection.drop()

Removes a collection from the database. The method also removes any indexes associated with the dropped collection. The method provides a wrapper around the drop command.

But how can I drop it from the command line?

1 Answer

0 votes
by (94.3k points)

You can use the below-mentioned code to drop a collection in MongoDB:-

mongo <dbname> --eval 'db.<collection>.drop()' db.<collection>.drop()

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...