我想在 JSON 对象中填充,但它不起作用。这是代码。当我记录Group变量的响应时,我仍然得到的响应是 objectId
人口
var Groups = await GroupModel.find({ownerUser : user.battletag}).populate([
{
path: "selectedInstance",
model: "Instances"
},
{
path: "createdAs",
model: "Characters",
populate: {
path: "race",
model: "Races"
}
},
{
path: "characters",
populate: {
path: "character",
model: "Characters"
}
}
]).exec();
图式
var GroupSchema = new Schema({
createdAs: {type: Schema.Types.ObjectId, ref: 'Characters'},
description: String,
minimumItemLevel: Number,
voiceChat: String,
completedAchievements: [{ type: Schema.Types.ObjectId, ref: 'Achievements' }],
selectedInstance: { type: Schema.Types.ObjectId, ref: 'Instances' },
instanceDifficulty: String,
private: Boolean,
characters: [{character: { type: Schema.Types.ObjectId, ref: 'Characters' }, role: String}],
queue: [{ type: Schema.Types.ObjectId, ref: 'Characters' }],
ownerUser: String,
groupSignature: String,
status: {type: String, default: "Open"},
maxPlayers: Number,
minPlayers: Number,
expansion: String,
createDate: {type: Date, default: Date.now}
});