Closed eliasjnior closed 4 years ago
By the way, the workaround was don't set and update, but using:
await OrderModel.findByIdAndUpdate(orderId, data)
For what I searched, the problem is here: https://github.com/mongodb-js/mongoose-autopopulate/blob/master/index.js#L57
But I still didn't figure out how to fix.
Looks like I was adding auto populate plugin in each subdocument schema, this was causing the problem. If I remove the plugin from subdocuments, the fields that I set as autopopulate
still working, so no need to apply plugin on subdocuments.
Now registering this plugin on a nested schema is a no-op rather than throwing an error on post('save')
I got this error trying to:
Here's my schema for Order:
And here for order address:
And finally for order products:
The message recommends use
doc.populate("arr.0.path")
thandoc.arr[0].populate("path")
. I'm using version0.12.1
from NPM.