如何删除TTLforms的MongoDB集合?

我在node.js上使用mongoose 我正在testing生存时间function,并将我的文档设置为在数据库模式中的X时间后过期:

var adInfos = new mongoose.Schema({ inf : { type: Object, required: false }, created: { type: Date, default: Date.now, expires:60 } }); 

这似乎是正确的,但删除expires属性后,新的文件似乎仍然过期。

我也尝试设置expires: falseexpires:0但也不起作用。

Mongoose不会删除索引,因此,如果更改模式中的索引属性,则只有在手动删除现有索引后才能生效。

不知道你的集合名称是什么,但在shell中,它会是这样的:

 db.adInfos.dropIndex('created_1') 

使用db.adInfos.getIndexes()查看集合上的索引。