Node.js 返回了双重填充try但为null的对象

Node.js 返回了双重填充try但为null的对象,node.js,mongoose,populate,Node.js,Mongoose,Populate,我试图从数据库检索数据时遇到问题 它适用于我所有的发现,芬顿等 但是,当我尝试为一个查找执行两次填充时(请参见下面的代码),它返回一个UnitCode null,但是对于MAP attribute,我得到了正确的对象,没有任何问题,所以为什么它只适用于一个plz NodeJs函数: function retrieveResponses(ID,callback){ ResponseDatabase. find({ MAP: ID }). populate('UnitCode'). popu

我试图从数据库检索数据时遇到问题

它适用于我所有的发现,芬顿等 但是,当我尝试为一个查找执行两次填充时(请参见下面的代码),它返回一个UnitCode null,但是对于MAP attribute,我得到了正确的对象,没有任何问题,所以为什么它只适用于一个plz

NodeJs函数:

function retrieveResponses(ID,callback){
 ResponseDatabase.
 find({ MAP: ID }).
 populate('UnitCode').
 populate('MAP').
 exec(function (err, data) {     

     callback(data);
 });
};
集合架构:

var nameSchemaRS = new mongoose.Schema({
 MainClass: String,
 BookingClass: String,
 CarID: String,
 UnitCode:{type: String, ref: 'Unit' ,required: [true,'No post id found']},
 MAP:{type: String, ref: 'MAP' ,required: [true,'No post id found']},
 Deck:Number,
 Orientation:String,
 Position:String, 
 }, {
 versionKey: false 
});

顺便说一句,我检查了代码是否相同,所以我不知道我的错误在哪里…

类型应该是
ObjectId
不是stringIt用于MAP,为什么?我发现我的错误,这只是因为我在表'Unit'上设置了_id,所以我更改了模式,现在它工作得很好,伟大的人!!!干杯