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

168
Vistas
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 Respuestas
Responde la pregunta

0

Try chaining toArray method after find

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

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 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