Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
Setting TTL doesn't remove the records in MongoDB

I use Robo Mongo to run my Mongo DB queries. I have a collection which has 'requestReceivedTimestamp' column that holds date time (Example: 12/13/2016 23:18:56 EST). I have used the below commands to setup the TTL Expiry index on this column. For some reason, i don't see the records getting removed. Am i doing something wrong here?

db.logging.createIndex( { "requestReceivedTimestamp": 1 }, { expireAfterSeconds: 2592000 } ) --> Ran this command to create a TTL index on 'requestReceivedTimestamp'

To Enable the MongoDB TTL Monitoring: db.adminCommand({setParameter:1, ttlMonitorEnabled:true}); --> This command to make sure the ttlMonitor is ON. I don't know how to see, if it is ON or OFF, so i had run this command to turn it ON.

This is how data looks like using mongo DB.

How the collection looks like in RoboMongo

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

The value of requestReceivedTimestamp should be an ISO Date (maybe a timestamp): https://docs.mongodb.com/manual/tutorial/expire-data/

To create an ISO Date:

new Date()
new Date('July 22, 2013 14:00:00')
over 4 years ago · Santiago Trujillo Relatório

0

Thanks Paul Rey. After inserting the column data using new Date(), i was able to the delete the rows after indexing the new column with ttl expiry date. Used the same command - db.logging.createIndex( { "recordCreateDate": 1 }, { expireAfterSeconds: 2592000 } )

Image of the inserted record

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda