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

211
Vistas
In Mongoose, what would I use .pre() middleware function for?

I am just wondering what mongoose .pre('validate') and .pre('save') would be used for. I know how it works and what it does, but I am not sure what situation I could have that I would use it for. Couldn't I just do everything I need within code? And what is difference between validate and save?

Sorry if these are dumb questions, I've done my research but not sure when to use these features

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

0

We use the .pre() function that is executed before or after a certain action that you specify. When you want to run a function every time before you save a document in the DB, we would you a pre-hook for that.

Example : Before saving a user to the database, you could call a function that would log the user into to a logging service.

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