遍历猫鼬文档列表返回0

时间:2019-04-27 08:45:13

标签: arrays node.js mongodb mongoose

我有一个猫鼬模式,该模式由作者对象,内容,注释,棚,creationDate,creationIP和creationLocation组成。问题是,如果我遍历Application.find()返回的列表,它似乎找不到任何文档。

我的代码

这在async()=> {}函数中。

const applications = await Application.find(
    { _id: user.notReviewed },
    { _id: true, content: true, creationDate: true, author: true, votes: true });

console.log(applications)

for (application in applications) {
    console.log(application)
}

返回

[ { author: { username: 'Dextication', _id: '1234567890' },
    votes: [],
    creationDate: 2019-04-26T15:24:37.000Z,
    _id: 5cc321e529b4745b3474a641,
    content: 'Yeah, well that was fun!' } ]
0 // this should be the above argument in the array

0 个答案:

没有答案