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

173
Views
Mongoose returns uniterable array from Schema.find({})?

I am trying to retrieve some data from my mongo DB, and it returns all what I need, but its in some weird structure that I can't seem to get into, can't for loop through it, can't iterate with i, can't iterate through Object.entries, either!

The data:

[
  {
    _id: 666,
    username: 'VioPaige',
    email: '<email>',
    verifcode: 'noverifcode',
    confirmed: false
  },
  {
    _id: 73,
    username: 'DogeKnight',
    email: '<email>',
    verifcode: 'noverifcode',
    confirmed: true
  },
  {
    _id: 1000,
    username: 'BlockAccount',
    email: '<email>',
    verifcode: 'noverifcode',
    confirmed: true
  }
]

Is there any way I can still iterate through it?

Thanks for reading!

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

0

Try chaining toArray method after find

Find({}).toArray(function(err, data) {
 console.log(data);
}
about 4 years ago · Juan Pablo Isaza Report

0

I already had same problem.

Try to use lean option. Mongoose With Lean

const docs = await YourModel.findOne().lean();
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!