通过设置TTL使集合中的数据过期
1,在特定的时间过期文档
db.ediInterfaceDocment.createIndex({"expireAt":1},{ expireAfterSeconds: 0 })
算了,不写了,看mongoDb中文社区文档吧
https://docs.mongoing.com/indexes/index-properties/ttl-indexes/expire-data-from-collections-by-setting-ttl
本文介绍如何使用MongoDB的TTL特性来实现集合中数据的自动过期删除功能。通过创建带有expireAfterSeconds属性的索引,可以指定文档在特定时间后自动删除。
1,在特定的时间过期文档
db.ediInterfaceDocment.createIndex({"expireAt":1},{ expireAfterSeconds: 0 })
https://docs.mongoing.com/indexes/index-properties/ttl-indexes/expire-data-from-collections-by-setting-ttl
1857
1732

被折叠的 条评论
为什么被折叠?
