-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Populating virtual count field returns the sum of all referencing documents for all populated documents #7573
Comments
Can you confirm if this is the same issue? A "developers" list in a "team" collection. The developers have two virtual fields related with "tickets":
Code ready to run
OutputThe tickets array is almost perfect (except for the developer who doesn't have tickets...) but the tickesCount doesn't match with de tickets.length, it's equal to the number of developers.
|
Hi, I think this might have regressed. I have the following example
When I |
@yharaskrik it hasn't regressed, because we have tests for this issue and they're passing. Please open a new issue and follow the issue template. |
Do you want to request a feature or report a bug?
What is the current behavior?
I've a model with a virtual property (let's call it "numS3") that counts the number documents in another model (https://mongoosejs.com/docs/populate.html#count). When I populate this virtual property in a chain, "numS3" is not the sum of each document, it's the sum of all "numS3" of all documents found.
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
Populating the virtual "count-property" numS3 should return the number of documents of Schema3 and not the sum of all Schema3 that referencing Schema2.
Please mention your node.js, mongoose and MongoDB version.
node.js: 8.11.4
mongoose: 5.4.16
MongoDB: 3.6
The text was updated successfully, but these errors were encountered: