Capped collection in mongo

What is a Capped collection in MongoDB? 

Capped collections are fixed-size collections that support high-throughput operations that insert and retrieve documents based on insertion order. Capped collections work in a way similar to circular buffers: once a collection fills its allocated space, it makes room for new documents by overwriting the oldest documents in the collection.


How to create a Capped collection in Mongo?

You must create capped collections explicitly using the db.createCollection() the method followed by given below query.

db.createCollection( "beingCodeExpert", { cappedtruesize100000 } )

Check whether a collection capped or not.

db.collection.isCapped()

How to apply capped an existing collection?

db.runCommand({"convertToCapped""beingCodeExpert"size100000});

No comments:

Post a Comment