If you want to limit the fields to AlbumSong, you can simply use the function provided by mongoose , for example:
AlbumSong.find(condition)
.select('_id category poetId name nameHindi invalid status')
.deepPopulate(...)
.
:
var userSchema = new Schema({
name: String,
email: String
});
var CommentSchema = new Schema({
author : {type: Schema.Types.ObjectId, ref: 'User'},
title: String,
body: String
})
var PostSchema = new Schema({
title: String,
author: { type: Schema.Types.ObjectId, ref: 'User' },
comments: [{type: Schema.Types.ObjectId, ref: 'Comment'}],
body: String
});
PostSchema.plugin(deepPopulate, {
populate: {
'author': { select: 'name' },
'comments': { select: 'title author' },
'comments.author': { select: 'name' },
}
});
deepPopulate author, comments comments.author.
, :
Post.find().select('title author comments').deepPopulate('author comments.author').exec(function(err, data) {
});
:
[{
"_id": "56b74c9c60b11e201fc8563f",
"author": {
"_id": "56b74c9b60b11e201fc8563d",
"name": "Tester"
},
"title": "test",
"comments": [
{
"_id": "56b74c9c60b11e201fc85640",
"title": "comment1",
"author": {
"_id": "56b74c9b60b11e201fc8563e",
"name": "Poster"
}
}
]
}]
, title (body ).
.