Using MongoAlchemy, is it possible to have a DocumentField that can be one of two types? E.g:
class A(Document):
foo = StringField()
class B(Document):
bar = StringField()
class C(Document):
child = DocumentField(A or B)
I thought of a few options that might work:
- Give
A
andB
a common parent and then dochild = DocumentField(CommonParent)
. - Write a custom
Field
that overridesDocumentField
, but changes the validator to search through a list of types, instead of one. - Just use an
AnythingField
. Kinda defeats the point.
But wondered if it was already done?