我有一个结构如下的摘要模式
{
sender: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
required: true,
},
summary: {
type: String,
},
sent: {
type: Date,
default: Date.now,
},
}
);
那么convo模式:注意:此模式中的summary是一个objectId数组,convo在获取后返回一个对象数组,sender位于填充summary字段后获得的每个对象中
{
lastMessage: {
type: mongoose.Schema.Types.ObjectId,
ref: "messages",
},
members: {
type: [mongoose.Schema.Types.ObjectId],
ref: "User",
required: true,
},
summary: {
type: [mongoose.Schema.Types.ObjectId],
ref: "summary",
},
gigDetails: {
type: mongoose.Schema.Types.ObjectId,
ref: "Gig",
},
}
除了已经填充的summary字段之外,我还想在convo模式的summary数组中填充sender字段。我该怎么做呢?
2条答案
按热度按时间oprakyz71#
你可以这样做:
ev7lccsx2#