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

100
Vistas
Unable to access contents of returned mongodb/mongoose object

I am trying to retrieve values from "UserKid" collection where "fname" and "Parent_id" are used as conditions. It returns "contentLinkIds" in "det1". I've checked by printing it on the console that it is returning the required content. However, I am not able to access the key-value pairs within the returned object.

UserKid.find({Parent_id:ObjectId(det._id).toString(),fname:fname},'contentLinkIDs', function(err1, det1){
 console.log("Det1:" + det1);
 console.log("DET1 id:"+ det1._id);
 console.log("contentLinkIDs: "+det1.contentLinkIDs);
/*some code here*/
});

Output on console:

 Det1:{ _id: 58e08c96f36d2878e036cf21,
 contentLinkIDs: [ '58e2dea6f36d283c9c86dd14' ] }
 DET1 id:undefined
 contentLinkIDs: undefined

Whats going wrong here?

Additonal info: I am using mongoose in Node.js/Express to connect to mlab.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

For anyone else who gets these errors, When I use "find", the object returned seems to be an array of objects. So det1[0]._id and so on can access the content instead.

about 4 years ago · Santiago Trujillo 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