I am using MongooseDeepPopulate package for the project. I have SchemaA, SchemaB, SchemaC, SchemaD. My SchemaD, SchemaC are connected to SchemaB and SchemaB is connected to SchemaA.
I have done like this.
var deepPopulate = require('mongoose-deep-populate')(mongoose);
AlbumSong.plugin(deepPopulate, {
populate: {
'song.category': {select: 'name status'},
'song.poetId': {select: 'name status'}
}
});
song
is connection further with category and poetId. I am successfull with limiting fields from category
and poetId
. But I wish to limit fields from intermediate model song
as well. My find query is like
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);
});
Where I have mistaken.