Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on populating top-level document paths #8298

Open
vkarpov15 opened this issue Nov 3, 2019 · 0 comments
Open

Remove dependency on populating top-level document paths #8298

vkarpov15 opened this issue Nov 3, 2019 · 0 comments
Assignees
Labels
refactor This is a purely internal change for making Mongoose internals easier to understand and work with

Comments

@vkarpov15
Copy link
Collaborator

Re: #8273 and #8247, it looks like we sometimes depend on setting populated() in the top-level document (

mongoose/lib/document.js

Lines 1151 to 1159 in dfde779

if (this.ownerDocument) {
popOpts = { [populateModelSymbol]: val[0].constructor };
this.ownerDocument().populated(this.$__fullPath(path),
val.map(function(v) { return v._id; }), popOpts);
} else {
popOpts = { [populateModelSymbol]: val[0].constructor };
this.populated(path, val.map(function(v) { return v._id; }), popOpts);
}
didPopulate = true;
) and sometimes we don't (

mongoose/lib/document.js

Lines 1137 to 1139 in dfde779

this.populated(path, val._id, { [populateModelSymbol]: val.constructor });
didPopulate = true;
}
) . The latter is the better approach because once you have populated paths within a document array, or populated paths within a single nested doc within an array, it becomes increasingly difficult to figure out populated values for the subdocument you're looking at.

@vkarpov15 vkarpov15 added the refactor This is a purely internal change for making Mongoose internals easier to understand and work with label Nov 3, 2019
@vkarpov15 vkarpov15 added this to the 5.x Unprioritized milestone Nov 3, 2019
@vkarpov15 vkarpov15 modified the milestones: 5.x Unprioritized, 5.13 May 10, 2021
@vkarpov15 vkarpov15 self-assigned this May 17, 2021
@vkarpov15 vkarpov15 modified the milestones: 5.13, 5.x Unprioritized, 6.0 Jun 28, 2021
@vkarpov15 vkarpov15 modified the milestones: 6.0, 5.x Unprioritized Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor This is a purely internal change for making Mongoose internals easier to understand and work with
Projects
None yet
Development

No branches or pull requests

1 participant