7

Anyone know the commands to drop a collection of documents and also drop a gridfs database?

1 Answer 1

11

To delete a collection, you can either call the drop() method on it, or use the drop_collection() method on the database object:

my_collection = db['collection_name']
my_collection.drop()

# Or...

db.drop_collection('collection_name')

GridFS files are stored in a collection called fs by default. To delete the GridFS files, just drop that collection:

db.drop_collection('fs')
Sign up to request clarification or add additional context in comments.

2 Comments

It might take a while until the effects of this command are visible :-)
In current versions of mongodb, GridFS documents are stored in two collections, 'fs.files', and 'fs.chunks'. You'd want to drop them both.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.