Skip to content

Adding TTL index to Doc schema #4

Description

@MrVSiK

Currently, cron service is being used to find documents that have expired and deleted them. Instead of that, we can use TTL index in a document using createdAt key in the doc. This will allow MongoDB to automatically find and remove expired documents.

More on TTL Index

Example:

// expire docs 3600 seconds after createdAt
new Schema({ createdAt: { type: Date, expires: 3600 }});

I would like to work on this

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions