-
Notifications
You must be signed in to change notification settings - Fork 45
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
Current mongoose includes schema inheritance and discriminatorKey functionality #17
Comments
I would personally suggest referencing that discriminators on the root level exist in Mongoose core now, so the use of the plugin should maybe be forfeited to promote using the new core version and making it better. However, if you can post the error you get when being initialized (& maybe some code), that'd be more helpful. All mongoose does is check if the discriminatorKey exists in the document and if that model has a discriminator defined with whatever discriminatorKey's value is in the document. Otherwise, the model is hydrated as it is normally. |
@j So in your opinion what is the best way to implement schema inheritance currently? Maybe you could reference an example? Until now I've been using mongoose-schema-extend plugin to accomplish this task, but maybe there is a better approach since discriminators exist in Mongoose core. |
I'd like to know also if this library is essentially deprecated in light of the functionality built into Mongoose core. |
@neverfox Which mongoose built-in functionality do you refer to? Update Just have reread my previous comment, probably you are talking about the discriminators |
@voz Yes, discriminators. However, just fyi, there is an open issue about them regarding some strange behavior with "child" models. |
@neverfox will watch the issue, thanks for the information. |
With merging of Automattic/mongoose#1647, mongoose now includes schema inheritance and discriminatorKey functionality that breaks mongoose-schema-extend.
mongoose now sets the discriminatorKey schema option to '__t' by default, which leads to non-inherited schemas to throw an error when being initialized.
The text was updated successfully, but these errors were encountered: