-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Description
What is the current behavior?
A model containing an array of another schema, which itself has a reference to another model. When calling .populated('nested.reference') the result doesn't appear to match the length of the array if you have pushed new items into the array.
https://gist.github.com/dave-continuum-media/09848138ae86508d891c65bddc537b20
What is the expected behavior?
.populated('nested.reference') should return undefined if none of the items are populated but an array of equal length to the sub-schema array if some or all are.
Currently it takes extra effort to tell if a document subschema array has been fully populated:
const populated = doc.populated('nested.reference');
if (populated === undefined || populated.length < doc.nested.length) {
await doc.populate('nested.reference');
}
Metadata
Metadata
Assignees
Labels
confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.We've confirmed this is a bug in Mongoose and will fix it.