mongodb-js / mongoose-autopopulate

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

don't works with insertMany #79

Open Hisham-TK opened 3 years ago

Hisham-TK commented 3 years ago

insertMany method at mongoose like create many this plugin has to inject it's middleware at insertMany pre-post to populate on createMany

https://mongoosejs.com/docs/api.html#model_Model.insertMany

vkarpov15 commented 3 years ago

This is a little trickier than expected because there's no way to get insertMany() options in post('insertMany') hooks with Mongoose. That's something we need to work on: the context for insertMany() hooks should be something that enables accessing the options.

As a workaround, we're adding a populate option for insertMany() to Mongoose. That will enable this plugin to access insertMany() options, and we'll have a fix for this within the next couple of days :+1: