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

87
Vistas
How do I make a function tick atomically if the document is not modified after a certain period of time

Hello I am working with mongoose/mongodb and have this data structure

{
   step: "Lorem",
   status: "in-progress",
   bool: true,
   startedAt: Date.now(),
   inactive: false
}

how do I make it so if there are no changes to the first three attibutes after a certain period of time inactive is set to true

Thanks for any assistance!

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

0

You need an extra field updateAt, everytime step or status or bool changed, you also need to change updateAt.

Finally you can check updateAt.

{
   step: "Lorem",
   status: "in-progress",
   bool: true,
   startedAt: Date.now(),
   updateAt: Date.now(),
   inactive: false
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

Use a CRON, here is some pseudo code

//query
{$lte: updatedAt: today, subtracted by 2months}
//update
{$set: attr to 'whatever you want'}
//db call
db.collection.updateMany(query, update)
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