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: prevent discriminated models from being created before their base model #244

Merged
merged 3 commits into from
Sep 1, 2020

Conversation

karrui
Copy link
Contributor

@karrui karrui commented Sep 1, 2020

Problem

Using EncryptSubmission Model without having compiled Submission Model causes EncryptSubmission Model to be without core keys like form

This problem extends to Form model as well.

Closes #243

Solution

Bug Fixes:

  • Fix possible race conditions by only returning discriminated models after compiling/retrieving their base instead of compiling from scratch.

Note: The usual way of exporting discriminated models should be employed once we have fully migrated over to Typescript.

export const EmailFormModel = FormModel.discriminator(ResponseMode.Email, EmailFormSchema)
export const EncryptFormModel = FormModel.discriminator(ResponseMode.Encrypt, EncryptedFormSchema)

@karrui karrui requested a review from arshadali172 September 1, 2020 04:11
@arshadali172 arshadali172 merged commit c72d433 into develop Sep 1, 2020
@karrui karrui deleted the fix/mongoose-discrimination branch September 1, 2020 10:03
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.

Unclear dependency between EncryptSubmissionModel and SubmissionModel
2 participants