How to remove documents from a capped collection in MongoDB

You can’t remove one or all documents from a capped collection in MongoDB. BUT! you can drop the collection!

Execute the following command:

db.getCollection('myCollection').drop()

The result for me is:

true

There you go, quick and easy.

Sources

  • https://docs.mongodb.com/manual/core/capped-collections/
  • https://stackoverflow.com/questions/33048282/how-to-remove-a-document-from-the-capped-collection

Leave a Comment

Your email address will not be published. Required fields are marked *