Mongoose select in two level population

i have such query

 Order.find({patient:req.user._id})
        .populate({
            path:'doctor',
            populate:{
                path:'specialization',
                select:'-_id'
            },
        })

in this query, if I remove select - everything is working, but when i want select fields which i want (not all ), (select as option working on first level population ) populate no working, can you help me?

Upvotes: 2

Views: 406

Answers (1)

Thomas Wolfe
Thomas Wolfe

Reputation: 638

This may be occurring because your nested populate is an option for .populate({}) and thus may not have a select option. See the Populating across multiple levels section of this documentation.

You could also try recursively populating. See this answer for more details.

Upvotes: 1

Related Questions