mongodb capped collections with TTL

502 Views Asked by At

I have an application that allows users to chat with other users,

I only want to store X messages per each conversation, AND each message must be deleted after 1 month since its creation (TTL)

MongoDB support capped collections with TTL?

The documentation says: https://docs.mongodb.org/manual/core/capped-collections/#automatically-remove-data-after-a-specified-period-of-time

For additional flexibility when expiring data, consider MongoDB’s TTL indexes, as described in Expire Data from Collections by Setting TTL. These indexes allow you to expire and remove data from normal collections using a special type, based on the value of a date-typed field and a TTL value for the index.

TTL Collections are not compatible with capped collections.

I think not, so, there is any alternative to accomplish it?

Thanks

0

There are 0 best solutions below