【问题标题】:how can i populate objectId inside another objectId in mongoose我如何在猫鼬的另一个 objectId 中填充 objectId
【发布时间】:2020-08-15 10:11:18
【问题描述】:

我有一个聊天列表,其中有 messageId 作为对象 id 引用消息模型,并且该消息模型有消息数组,其中 senderId 作为 objectId 引用用户模型,在用户控制器中我喜欢填充聊天列表.messageId.messages.senderId 我尝试但不工作。

这是我希望它工作的代码

.populate('chatList.messageId.messages.senderId')

【问题讨论】:

    标签: node.js angular express mongoose


    【解决方案1】:

    您可以关注此代码

    
    > ref_id means model reference id
    
    .populate("ref_id")
    

    【讨论】:

    • 然后你可以再次填充
    • objectid 在不同的模型中
    猜你喜欢
    • 2020-07-25
    • 2020-05-25
    • 2017-03-23
    • 2017-04-06
    • 2021-03-03
    • 2019-09-16
    • 1970-01-01
    • 2017-04-25
    • 2013-07-27
    相关资源
    最近更新 更多