Closed irisked closed 4 years ago
Yeah unfortunately this is very difficult to support with the current way mongoose-autopopulate works. It's based entirely on pre('find')
and pre('findOne')
hooks, which don't get fired for the child model when you do find()
on the parent model.
This is a must-have for a project I have in the works. Has there been any movement? Any workarounds?
@jmikrut not yet. You would need to call populate()
manually, Base.find().populate('items')
, or write your own query middleware.
Autopopulate don't work if populated field are in child schema.
UPD. Works correctly if query "based" on child schema. E.g. ChildSchema.find({}), but don't work if BaseSchema.find({})