Unlike normal collections, fixed collections must be created before they are used, and fixed collections can be created using the Create command. In the shell, you can use the Db.createcollection function:
Create a fixed collection of size 1024 bytes db.createcollection ("capped", {capped:true,size:1024});//Create a size of 1024 bytes, Fixed set db.createcollection ("capped", {capped:true,size:1024,max:100}) with a number of 100 documents;
It is important to note that the size parameter is a required option and the Max parameter is optional. Regardless of which limit is reached, the new document that is inserted then squeezes the old document into the collection, the number of documents in the fixed collection cannot exceed the number of documents set, and the size of the fixed collection cannot exceed the size of the set.
Once a fixed set is created, it cannot be changed, and if you want to modify the properties of a fixed collection, you can only delete and then create it. Therefore, you should carefully consider the size of a large fixed set before you create it.
In addition, you can use the converttocapped command to convert a regular collection to a fixed collection:
Db.runcommand ({converttocapped: "Test", size:1024, max:100});
Note that you cannot convert a fixed collection to a non-fixed collection.
This article is from the architect's path blog, so be sure to keep this source http://lizhuquan0769.blog.51cto.com/2591147/1762000
"MongoDB" capped fixed size/quantity collection