Fixes #88. Please prioritize review, this library is heavily depended upon and needs to support the latest version of Mongoose. We've already moved our production codebase to a local version of the library due to this breakage, and anyone using the library for the first time will have this issue.
As explained in the v5 to v6 migration guide, execPopulate() is no longer a function. This plugin only uses execPopulate() in the post-save middleware, after chaining .populate() calls on the document instance. However, population chaining is no longer allowed on documents. The fix here was to use different population methods depending on context: in a query context, nothing changed. But for document context, we store all of the paths to populate in an array as we iterate over the schema paths, and then return the population promise at the end of the middleware.
Happy to make any changes, just let me know what to prioritize. Looping in @connorstevens and @ssudler who are happy to help as well.
Fixes #88. Please prioritize review, this library is heavily depended upon and needs to support the latest version of Mongoose. We've already moved our production codebase to a local version of the library due to this breakage, and anyone using the library for the first time will have this issue.
As explained in the v5 to v6 migration guide,
execPopulate()
is no longer a function. This plugin only usesexecPopulate()
in the post-save middleware, after chaining.populate()
calls on the document instance. However, population chaining is no longer allowed on documents. The fix here was to use different population methods depending on context: in a query context, nothing changed. But for document context, we store all of the paths to populate in an array as we iterate over the schema paths, and then return the population promise at the end of the middleware.Happy to make any changes, just let me know what to prioritize. Looping in @connorstevens and @ssudler who are happy to help as well.