Meteor Collections that expire

前端 未结 2 1302
无人及你
无人及你 2021-01-21 10:12

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 betw

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-21 10:57

    I would recommend indexing the particular field in the collection with a TTL parameter, this will ensure that documents expire after a specified time.

    Do it from the Mongo shell like so:

    db.myCollection.ensureIndex( { "fieldName": 1 }, { expireAfterSeconds: 3600 } )
    

提交回复
热议问题