Feature Request - Deep Populate Support in Mongoose Virtuals #14227
Labels
enhancement
This issue is a user-facing general improvement that doesn't fix a bug or add a new feature
new feature
This change adds new functionality, like a new method or class
Milestone
Prerequisites
馃殌 Feature Proposal
Issue Description:
I would like to request the addition of a feature that supports deep populate in Mongoose virtuals. Currently, the populate method allows for deep population of related data from other collections/models, but this functionality is not available when using virtuals.
Use Case:
In scenarios where virtuals are used to define relationships between models, the lack of deep populate support poses a limitation. For example, consider a case where a User model has a virtual field customerId, and there are other models such as Subscription and Product. To retrieve related data deeply nested, it is currently not possible with virtuals.
Example with populate method:
Requested Feature:
I propose adding deep populate support to virtuals in Mongoose. This would enhance the flexibility and utility of virtuals, enabling users to retrieve related data from multiple levels of nesting.
Suggested Implementation:
The implementation could follow a syntax similar to the populate method, allowing users to specify the path, model, and other relevant options for each level of deep population within a virtual.
Additional Information:
Mongoose Version: [Specify the version you are using]
Node.js Version: [Specify the version you are using]
Thank you for considering this feature request. I believe that adding deep populate support to virtuals will further empower developers to create expressive and efficient MongoDB queries with Mongoose.
Motivation
No response
Example
The text was updated successfully, but these errors were encountered: