简体   繁体   English

MongoDB 限制集合大小

[英]MongoDB limit the collection size

Do we have a limiting option for collections?我们是否有 collections 的限制选项? Maximum 10 rows(objects) for example.例如,最多 10 行(对象)。 If I insert one more row and if there are already more than ten rows in the collection, the oldest one pops out and deleted?如果我再插入一行并且集合中已经有十多行,那么最旧的行会弹出并删除吗?

you can limit the number of documents with Capped Collections :您可以使用Capped Collections限制文档数量:

db.createCollection("log", { capped : true, size : in_bytes, max : number_docs } )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM