如何使用mongoose创建上限集合? [英] How do you create a capped collection using mongoose?
本文介绍了如何使用mongoose创建上限集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用Mongoose创建一个上限集合,但是下面创建一个没有限制的集合:
I'm trying to create a capped collection using Mongoose, however the following creates a collection that is not capped:
var schema = new mongoose.Schema(
{
Name: { type: String },
Text: { type: String }
},
{
capped: { max: 5, size: 1000000 }
});
我很确定我正确地跟踪了文档的例子,错误。
I'm pretty sure I'm following the documentation's example properly, but clearly I'm doing something wrong.
推荐答案
new Schema({..}, { capped: { size: 1024, max: 1000, autoIndexId: true } });
这篇关于如何使用mongoose创建上限集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文