簡體   English   中英

MongoDB TTL 索引不刪除過期記錄

[英]MongoDB TTL index does not remove an expired record

我在我的集合的created_at字段上創建了一個 TTL 索引,以便在 30 秒后自動刪除文檔,但經過一段時間后(5 分鍾后),文檔沒有被刪除。 我閱讀了一些相關問題,我確信我的收藏中沒有錯字。 這是運行db[collectionName].getIndexes()后的 JSON

[
{
    "v" : 2,
    "key" : {
        "_id" : 1
    },
    "name" : "_id_",
    "ns" : "record_db.collectionName"
},
{
    "v" : 2,
    "key" : {
        "created_at" : 1.0
    },
    "name" : "created_at_1",
    "ns" : "record_db.collectionName",
    "expireAfterSeconds" : 30.0
}

] 這是一個示例文檔:

{
  "_id" : ObjectId("5fc3823af29f9d9eb1518857"),
  "record_path" : path/to/file,
  "timestamp" : 1606648392,
  "humantime" : "29/11/2020 18:12:58",
  "created_at" : ISODate("2020-11-29T18:12:58.859Z")
}

ISODate("2020-11-29T18:12:58.859Z") 還沒有發生。

 const iso = "2020-11-29T18:12:58.859Z" const date = new Date(iso); console.log(date.toString());

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM