fix(document): avoid using childSchemas.path for compatibility with pre-Mongoose-8.8 schemas #15131
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #15071
Summary
#15071 is a tricky situation where the user has a shared connection package that uses Mongoose 8.8, and a client npm package which defines schemas using Mongoose 8.5 but then defines models using the Mongoose 8.8 connection. And we added a new
childSchemas.path
property in 8.8.3 with #15029 that Mongoose 8.8.3 expects, but schemas from Mongoose 8.5 do not have.The "right" solution is to tell the user to ensure a consistent version of Mongoose, because we cannot realistically test that schemas from every version of Mongoose work with models from every other version of Mongoose. However, in the interest of not breaking code that previously worked, we can use this PR's more backwards-compatible approach.
Examples