Skip to content
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

fix(model): allow defining discriminator virtuals and methods using schema options #12326

Merged
merged 1 commit into from
Aug 28, 2022

Conversation

vkarpov15
Copy link
Collaborator

Fix #12246

Summary

We now support defining virtuals and methods using schema options, but that doesn't work well with discriminators unless the discriminator schema has the exact same virtuals and methods as the base schema.

With this PR, you can define additional virtuals on a discriminator schema using new Schema(definition, { virtuals: { myVirtual: () => 42 } })

Examples

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! 👍

@vkarpov15 vkarpov15 merged commit d5174a5 into master Aug 28, 2022
@hasezoey hasezoey added this to the 6.5.4 milestone Sep 1, 2022
@hasezoey
Copy link
Collaborator

hasezoey commented Sep 1, 2022

@vkarpov15 can this branch be deleted?

@AbdelrahmanHafez AbdelrahmanHafez deleted the vkarpov15/gh-12246 branch September 1, 2022 11:00
@Uzlopak
Copy link
Collaborator

Uzlopak commented Sep 1, 2022

@hasezoey
You can usually delete those branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Discriminator with virtuals not working with shema constructor options.virtuals
4 participants