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

268
Views
Error when trying to push something in mongodb

code

case 'setup':
    let serverSetup = ServerDoc.findOne({id: message.guild.id})

    if(serverSetup) return console.log(serverSetup)

    if(!serverSetup){
        let newServersetup = new ServerDoc({name: message.guild.name})
        newServersetup.save();
        console.log(newServersetup)
    }   

error https://pastecord.com/zutetugymo because I couldn't paste here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

What you think is your error is actually the result of the ServerDoc.findOne(). Since you are not using await or .then() when you are finding a document from your collection, this is what you get when you use .findOne(). To actually get the data instead of this, you just have to change your code to this:

case 'setup':
    let serverSetup = await ServerDoc.findOne({id: message.guild.id})
    if(serverSetup) return console.log(serverSetup)
    if(!serverSetup){
        let newServersetup = new ServerDoc({name: message.guild.name})
        newServersetup.save();
        console.log(newServersetup)
    } 
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!