【问题标题】:Nodejs attempting to populate user, however no successNodejs试图填充用户,但没有成功
【发布时间】:2019-09-27 13:11:15
【问题描述】:

对于我的应用程序,我成功地引用了其他文档,并将它们作为 objectid 存储在我的数据库(mongodb)中。但是,当尝试使用 .populate 时,不会出现人口。这是我的人口代码:

 User
    .find()
    .populate([
        {path: 'followers'},
        {path: 'following'}
    ])

【问题讨论】:

  • 请分享用户猫鼬模式

标签: javascript node.js mongoose


【解决方案1】:

https://mongoosejs.com/docs/populate.html

" Story. find(). populate({ path: 'fans', select: 'name' }). populate({ path: 'fans', select: 'email' }); // The above is equivalent to: Story.find().populate({ path: 'fans', select: 'email' });

"

我从未使用过 MongoDB,但也许这个链接中的 sn-p 可以提供帮助。

【讨论】:

    猜你喜欢
    • 2013-12-01
    • 1970-01-01
    • 2011-08-10
    • 1970-01-01
    • 2015-08-21
    • 2015-12-05
    • 2019-07-23
    • 2013-02-17
    • 2018-04-30
    相关资源
    最近更新 更多