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

Current mongoose includes schema inheritance and discriminatorKey functionality #17

Open
flore2003 opened this issue Nov 9, 2013 · 6 comments

Comments

@flore2003
Copy link
Contributor

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.

@j
Copy link

j commented Nov 24, 2013

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.

@voz
Copy link

voz commented Dec 7, 2013

@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.

@neverfox
Copy link

neverfox commented Apr 4, 2014

I'd like to know also if this library is essentially deprecated in light of the functionality built into Mongoose core.

@voz
Copy link

voz commented Apr 5, 2014

@neverfox Which mongoose built-in functionality do you refer to?

Update Just have reread my previous comment, probably you are talking about the discriminators

@neverfox
Copy link

neverfox commented Apr 5, 2014

@voz Yes, discriminators. However, just fyi, there is an open issue about them regarding some strange behavior with "child" models.

@voz
Copy link

voz commented Apr 5, 2014

@neverfox will watch the issue, thanks for the information.

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

No branches or pull requests

4 participants