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

104
Vistas
Mongoose update loop

I'm new to the world of mongoose and NodeJs, my problem occurs when I perform an update, effectively the update is carried out in the database but time later it happens again.

I perform the update as follows

router.post("/deleteLead", (req, res) => {
          console.log("----------- delete lead -------");
          const body = req.body;
          deleteLead(body);
});


  async function deleteLead(body) {
              const id_delete = body.leads.delete[0].id;
              const deleteLead = await Model_Lead.updateOne(
                { id: id_delete },
                {
                        is_deleted: true,
                }
              );
              console.log(deleteLead);
    };

this is the log of my aplication when i update a lead

----------- delete Lead -------
{
  acknowledged: true,
  modifiedCount: 1,
  upsertedId: null,
  upsertedCount: 0,
  matchedCount: 1
}
{
  acknowledged: true,
  modifiedCount: 1,
  upsertedId: null,
  upsertedCount: 0,
  matchedCount: 1
}
----------- delete  Lead -------
{
  acknowledged: true,
  modifiedCount: 1,
  upsertedId: null,
  upsertedCount: 0,
  matchedCount: 1
}
----------- delete  Lead -------
{
  acknowledged: true,
  modifiedCount: 1,
  upsertedId: null,
  upsertedCount: 0,
  matchedCount: 1
}
----------- delete Lead -------
{
  acknowledged: true,
  modifiedCount: 1,
  upsertedId: null,
  upsertedCount: 0,
  matchedCount: 1
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You're not awaiting the result of your deleteLead call. This means that your controller will just send off the request and move on.

When the request does resolve, it may happen while another controller is in the process of running, which would result in query results being logged in a way that looks like your controller hit MongoDB more than once, when it actually didn't.

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