2

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?

Community
  • 1
  • 1

1 Answers1

1

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.

Community
  • 1
  • 1
Thomas Wolfe
  • 638
  • 6
  • 11