mongodb-js / mongoose-autopopulate

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

Autopopulate not working with Array #83

Closed jariwbh closed 1 year ago

jariwbh commented 3 years ago

Hi,

I have noticed this issue where autopopulate suddenly stop working for array. if we restart node, it start populating.

Schema is more less like example:

var bandSchema = new Schema({ name: String, members: [{ type: ObjectId, ref: 'people', autopopulate: true }] }); bandSchema.plugin(autopopulate);

vkarpov15 commented 3 years ago

Without a more complete repro script, we won't be able to debug this. Our tests are passing so that code works as written. Can you please come up with more information as to what happens that causes autopopulate to stop working?

Teebo commented 1 year ago

Hi @vkarpov15 in my case all of a sudden populate is not working with a findOne query. I had to be more explicit like below for it to work

.populate({path: '...', model: '...'})

I do not see any change with my code that could cause this issue. With just .populate('path') it returns an empty array.

Any ideas why this is happening?

vkarpov15 commented 1 year ago

@Teebo without a repro script, hard to guess. Please open a new issue with a repro script.