我有一个猫鼬模式:猫鼬填充字段为空
mongoose.Schema({
state: {
type: {
action: 'string' ,
user: {type: mongoose.Schema.Types.ObjectId,
ref: 'User'},
at: 'date'
},
default: {}
},
log: [{
action: 'string' ,
user: {type: mongoose.Schema.Types.ObjectId,
ref: 'User'},
at: 'date'
}]
})
试图填充它
Model.findById(id).populate('state.user').populate('log.user').exec(cb)
在查询结果“用户”的日志项字段填充正确和“的状态。用户“为空。可能是什么问题?
我只是想要一个默认值,我看起来像一个bug。 – WHITECOLOR