Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
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 answers
Answer question

0

Try findOne

await serverdata.findOne(...)

Using find or findMany will return a cursor.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!