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

119
Vistas
Getting message exist in console while UID is not in database

I am trying to check if the UID exists in db. If it exist I want it not to write a data else write a data.

But for some reason I am getting exist when there is no such UID.

enter image description here

async function engagements(){
    // const db =  ;
    if (await Engagements.find({uid:"f60c7612-93f5-48b6-8039-94cf5668f6b4"})) {
        console.log("exist");
    }else{
        console.log("does not exist");
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I found the solution. The case that .find() returns an empty array which is equal to true. Basically I made a const and checked the array if it is empty or not

const db =  await Engagements.find({uid:"f60c7612-93f5-48b6-8039-94cf5668f6b4"});
    if (db.length > 0) {
        console.log("exist");
    }else{
        console.log("does not exist");
    }
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