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

Polymorphic Models #2

Open
codello opened this issue Apr 6, 2020 · 0 comments
Open

Polymorphic Models #2

codello opened this issue Apr 6, 2020 · 0 comments
Labels
enhancement New feature or request
Projects
Milestone

Comments

@codello
Copy link
Owner

codello commented Apr 6, 2020

Mongo collections can contain documents of different shapes. Polymorphic models implement support for having multiple models in one collection. This comes with the following restrictions:

  • The Collection name must be declared on the “root” polymorphic model.
  • Each document has a “_type” associated with it that contains the model class name. By enabling the option “qualified_names” the full qualified class names will be used.
  • On instantiation the Model tries to create an instance of the respective type (by checking its known subclasses). If no such type exists an error is raised.
  • It is an error to mark a submodel of a polymorphic model as polymorphic as well.

Polymorphic models and abstract models can be combined.

@codello codello added the enhancement New feature or request label Apr 6, 2020
@codello codello added this to the Version 1.0 milestone Apr 6, 2020
@codello codello added this to To do in Version 1.0 Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Version 1.0
  
To do
Development

No branches or pull requests

1 participant