我有一個貓鼬模式:貓鼬填充字段爲空
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