我正在为项目使用MongooseDeepPopulate包。我有 SchemaA、SchemaB、SchemaC、SchemaD。我的 SchemaD、SchemaC 连接到 SchemaB,而 SchemaB 连接到 SchemaA。
我已经这样做了。
var deepPopulate = require('mongoose-deep-populate')(mongoose);
AlbumSong.plugin(deepPopulate, {
populate: {
'song.category': {select: 'name status'},
'song.poetId': {select: 'name status'}
}
});
song
与类别和poetId 有进一步的联系。我成功地限制了category
和的字段poetId
。但我也希望限制中间模型song
的字段。我的查找查询就像
AlbumSong.find(condition)
.deepPopulate('song.category song.poetId')
// .deepPopulate('song.category song.poetId' , '_id category poetId name nameHindi invalid status') // I tried this as well to limit records from song model as well.
.exec(function(err, playlist) {
callback(err, playlist);
});
我在哪里弄错了。