Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a document from the capped collection?

When I try to remove a document in collection in MongoDB . It didn't remove because the collection is capped . My question is why? And is there a solution or other function can remove the document in this case?

like image 687
Mohamed.Benhazzez Avatar asked Oct 09 '15 22:10

Mohamed.Benhazzez


People also ask

What do you mean by capped collection?

Capped collections are fixed-size collections that support high-throughput operations that insert and retrieve documents based on insertion order.

What is capped document?

Capped collections restrict updates to the documents if the update results in increased document size. Since capped collections store documents in the order of the disk storage, it ensures that the document size does not increase the size allocated on the disk.

How do you check if the collection is capped or not?

You can check whether a collection is capped using the isCapped() method. This method returns true as the output if the specified collection is a capped one. Otherwise, it returns false.


1 Answers

No You cannot delete documents from a capped collection. And there is no possible workaround. The only thing you can do is drop() the collection.

like image 163
styvane Avatar answered Sep 19 '22 14:09

styvane