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

104
Views
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.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

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.

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