arrays - 遍历 mongoose 文档列表返回 0
问题描述
我有一个猫鼬模式,它由作者对象、内容、评论、cotes、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
解决方案
推荐阅读
- kotlin - 无法运行 Kotlin 项目(没有运行菜单)
- ios - 由于 xcodebuild 命令中的 CODE_SIGN_IDENTITY,CircleCI 构建失败
- html - 如何将文本与圆圈分开
- java - JAX-WS 将 Username-Token 添加到 SOAP-Header
- java - 405 Method Not Allowed when deploying artifact to Nexus
- javascript - Javascript 将一些计算结果一一追加到表行中
- javascript - 将锚标记作为自身传递给函数而不是通过 id
- android - 如何在 Nativescript 中的嵌套 ListView 上启用滚动?
- kubernetes - Promtail 忽略 extraScrapeConfigs
- firebase - 如何使用 dart 和颤振从 cloud firestore 数据创建每日 csv 文件?