【发布时间】:2021-05-23 03:37:27
【问题描述】:
我有一个问题... 我有这样的架构:
const chatSchema = new Schema({
[...]
title: {
type: String,
required: true
},
message: [
{
content: {
type: String,
required: true
},
creator: {
type: mongoose.Types.ObjectId,
required: true,
ref: 'User'
}
}
],
[...]
});
在我的 Node 后端,我怎样才能访问我的消息数组中的创建者实例?我不知道如何用 populate 编写查询...
谢谢大家! :-)
【问题讨论】:
-
这能回答你的问题吗? Populate nested array in mongoose