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

157
Vistas
Mongoose findOne() with a value higher than a var

So, I've been coding a bot on Discord. But when I tried to make 30 days auto-delete Tags, I been thinking that how do I find a document with a Time Expired Date in miliseconds that higher than current time.

const autoDeleteTag = function () {
 const currentTime = (new Date()).getTime()
 const findTag = tagSchema.findOne({ timeExpired: currentTime })
 if (findTag) return findTag.delete()
}
setInterval(autoDeleteTag(), 100)

But I don't know if this the right code? Because I think sometime it won't delete. Thanks!

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

0

If you want to compare dates (or values), you can you use the $gt, $lt etc. operators.

For example if you are looking for the older tags than current date:

tagSchema.findOne({ timeExpired: { $lt: currentTime } })
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