How to create TTL Index on long timestamp in MongoDB

前端 未结 1 1866
日久生厌
日久生厌 2021-01-18 15:13

In my mongo database I have field timestamp which holds time of creation in timestamp ie: \"timestamp\": 1544029233021 I want to create TTL index on this field,

相关标签:
1条回答
  • 2021-01-18 15:31

    The documents aren't being expired because the timestamp value is an integer.

    TTL indexes will only work on documents where the indexed field is a Date or holds an array of Dates:

    If the indexed field in a document is not a date or an array that holds a date value(s), the document will not expire.

    (https://docs.mongodb.com/manual/core/index-ttl/#expiration-of-data)

    0 讨论(0)
提交回复
热议问题