mongodb-js / mongoose-autopopulate

Always populate() certain fields in your mongoose schemas
Apache License 2.0
221 stars 36 forks source link

Issue with autopopulating a schema on itself #109

Closed sayeed1999 closed 1 year ago

sayeed1999 commented 1 year ago

I have a Skills collection each skill has a similar skills array so I am autopopulating the Skill inside similarSkills which is also a skill

so it is getting infinite loop and autopopulating on three four layers deep. can we restrict it to one layer deep only?

vkarpov15 commented 1 year ago

Yes, use the maxDepth option: https://github.com/mongodb-js/mongoose-autopopulate/blob/master/examples.md#it-can-limit-the-depth-using-maxdepth