我试图在非强制字段上使用populate可能与其他集合有关系,或者可能是空白的,当我尝试填充该字段时,它会给出错误
“转换为ObjectId失败的值”“路径”_id“”
码:
Paper.find(query).populate('1').populate('2').populate('3').exec(cb)
现在纸质文件中的3_id可能是空白的 .
架构就像
var paper_schema = new mongoose.Schema({
name: {
type:String
},
price: {
type: Number
},
1:{
type: mongoose.Schema.Types.ObjectId,
ref: 1
},
2:{
type: mongoose.Schema.Types.ObjectId,
ref: 2
},
3:{
type: mongoose.Schema.Types.ObjectId,
ref: 3
}
})