First = new mongoose.Schema({
name: String,
second: {type: Schema.Types.ObjectId, ref: 'Second'},
});
Second = new mongoose.Schema({
name: String,
third: {type: Schema.Types.ObjectId, ref: 'Third'},
});
Third = new mongoose.Schema({
name: String
});
First.find({}).populate({
path: 'Second',
populate: { path: 'Third'}
}).exec(function(err, result) {
console.log(result)
})
第一次填充没问题,但第三次总是null
。意思是我得到了这样的东西:
{
name: 1,
second: {
name: 2,
third: null
}}