Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
How to get TTL or expired document in mongodb?

I want to create ticketing system . Where ticket get cancelled after given period of time ?.For deleting after some time I am going to use indexing feature by MongoDb . But before it gets expire or after the expiry of that particular ticket I want to retrive or save it in different collection for future is it possible using mongodb ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

In the current version of MongoDB, 5.0.8 as I'm writing this, it's not directly supported, but it will be in MongoDB 6.0 (CF this jira ticket) and there is a workaround that you can use in the meantime (keep reading!).

Let me explain. What you are trying to do is:

  • set up a TTL index that will remove automatically the docs in your MongoDB collection when the time is passed by X seconds.
  • set up a Change Streams on this collection with a filter set to only keep delete operations.

In 5.0.8, this change stream event will only contain the _id field of the deleted document, and nothing else, as that's the only information currently available in the oplog.

In 6.0, you will be able to access the previous state of this document (so it's last state before being deleted).

That being said, there is a workaround that Pavel Duchovny explained in his blog post. You can easily accommodate his notification system to achieve your desired behaviour.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda