How to check if the collection is capped or not?
We can check whether the collection is capped or not with the isCapped() method in MongoDB. This method returns true is the specified collections capped collection. Otherwise, return, false.
Syntax:
db.Collection_name.isCapped()
Example:
db.student.isCapped()
After convert student collection to a capped:
Capped Collections in MongoDB
Capped collections are fixed-size collections means when we create the collection, we must fix the maximum size of the collection(in bytes) and the maximum number of documents that it can store. After creation, if we try to add more than documents to their capacity, it overwrites the existing documents. It supports high-throughput operations, that are useful when we insert and retrieve documents based on insertion order. The working of the capped collection is similar to circular buffers, which means once the fixed space is allocated for the capped collection, it creates/makes spaces for the new documents by overwriting the oldest documents in the given collection. Capped collection can also have _id field and by default, each _id field has an index.