I am currently using Nest’s SchemaFactory to setup my MongoDB models. Here is a link to their documentation:
https://docs.nestjs.com/techniques/mongodb#mongo
I was wondering how I could set a TTL index using this abstraction. I want every instance of a specific model to delete after 15 minutes.
2
Answers
The documentation that you linked has the following section:
Taking a look at the Mongoose docs, there is a special option for
Date
types, expires. This leads me to believe you could create a TTL index by including a Date field like so:Or: