Mongoose 5 to 6: Virtual populate lean does not return empty array on empty match #10992
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I'm migrating mongoose from 5 to 6 and upon testing I got this issue:
When I do find() with populate() on a virtual populate and lean()
I get a return undefined from campaignConsumeMonthlyMulti (code below)
If the current behavior is a bug, please provide the steps to reproduce.
Here my virtual in schema
Here the query
If the match matches data it works like a charm.
What is the expected behavior?
It should return an empty array like in mongoose 5.12.11
When I remove the lean() call : campaign.campaignConsumeMonthlyMulti getter give me the empty array.
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
NodeJs: 16.11.0
Mongoose: 6.0.13
MongoDB: 4.2.17
The text was updated successfully, but these errors were encountered: