问题描述
我想在 Meteor 中设置一个在客户端和服务器之间同步的会话绑定值.我认为这应该在集合中完成,因为 Session 不在客户端和服务器之间同步,对吗?重要的是在一定时间后清除数据,因为它实际上是我想要存储的 base64 编码图像.
I would like to set a session bound value that's synced between client and server in Meteor. I'm thinking that should be done in a Collection, since Session isn't synced between client and server, right? It's important that the data is cleared after a certain amount of time though, since it's actually base64 encoded images I'm looking to store.
是否可以为 Meteor Collection 设置到期日期?
Is it possible to set an expiration date for a Meteor Collection?
推荐答案
我建议使用 TTL 参数索引集合中的特定字段,这将确保文档在指定时间后过期.
I would recommend indexing the particular field in the collection with a TTL parameter, this will ensure that documents expire after a specified time.
像这样从 Mongo shell 中执行此操作:
Do it from the Mongo shell like so:
db.myCollection.ensureIndex( { "fieldName": 1 }, { expireAfterSeconds: 3600 } )
这篇关于过期的流星收藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!