mongodb - expireAfterSeconds doesnt work mongo -
using mongo 3.2
i set expireafterseconds 3 days, because not need more 3 days of data on collection, can see in db, still have data month ago. configured wrong.
the info gather db.runs.getindexes()
{ "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "guardian.runs" }, { "v" : 1, "key" : { "created" : 1 }, "name" : "created_1", "ns" : "guardian.runs", "background" : true, "expireafterseconds" : 259200 } an entry should deleted:
[ { "_id": "578c8aa25a3f72387073f2f0", "job_id": "573f62bf0e44a2796b6e9de1", "owner": null, "started": "2016-07-18t07:52:02.447z", "ended": "2016-07-18t07:52:14.119z", "status": "success", "result": { "success": [], "fail": [], "warning": [] } } ]
your document doesn't have created field ttl index references.
you need add created field docs time each doc created, or change ttl index reference either started or ended instead (assuming date values in database , not strings).
Comments
Post a Comment