Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

101
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda