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
Attempting to read mongoDB document properties

I'm trying to read the property levelenabled from a document stored in my MongoDB database. When I log the returned data to console after finding the document with the GuildID(discord.js) it logs the correct document but when I try to check a value in that data the property I'm checking is undefined. Here is my code:

const data = await serverdata.find({ //note serverdata is a reference to the serverdata Schema
        GuildID:message.guild.id
    });
    if(!data) return;
    console.log(data.levelenabled) //the output of this is undefined therefore I can not check the boolean status

And yes the function is async

I should also add that yes the property levelenabled exists in the document and when logging the GuildID it also is undefined.

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

0

Try findOne

await serverdata.findOne(...)

Using find or findMany will return a cursor.

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