Mongoose/MongoDB result fields appear undefined in Javascript

前端 未结 10 2261
囚心锁ツ
囚心锁ツ 2020-11-27 20:13

Is there something that I\'m missing that would allow item to log as an object with a parameter, but when I try to access that parameter, it\'s undefined?

What I\'ve

10条回答
  •  粉色の甜心
    2020-11-27 20:38

    I think using 'find' method returns an array of Documents.I tried this and I was able to print the title

    for (var i = 0; i < doc.length; i++) {
       console.log("iteration " + i);
       console.log('ID:' + docs[i]._id);
       console.log(docs[i].title);
    }
    

提交回复
热议问题