-
-
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
Getters for populate virtuals #9343
Comments
The reason why The We'll keep this open for a future feature suggestion. I'm thinking we can add support for something like this: matchSchema.virtual('gameTitle', {
ref: 'Game',
localField: 'game',
foreignField: '_id',
justOne: true,
options: {select: {'title': 1}},
set: doc => doc.title
}); Would that work for you @NikoFoX ? |
Shouldn't it be get instead of set? Analogically to schema path getters. |
|
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
Current populate virtual doesn't allow you to assign foreign object's field value as a virtual's returned value.
Currently doing:
and returning populated Match gives:
What is the expected behavior?
Same virtual should return Match object with gameTitle as String with current Game title.
I'm also wondering why the
select
option results in returning both selected field and _id field and not the field alone.The text was updated successfully, but these errors were encountered: