Conditional embedded document for mongodb objects
<p>I need help with thinking about data modeling (I am using python and mongoengine). I have an object that I would like to apply different classes of embedded documents to depending on another attribute the object has. </p>

<pre><code>class RunningSettings(EmbeddedDocument):
    max_distance = DecimalField()
    speed = DecimalField()
    ...

class WeightLiftingSettings(EmbeddedDocument):
    max_weight = DecimalField()
    reps = IntField()
    ...


class Workout(Document):
    name = StringField()
    description = StringField()
    date_created = DateTimeField(default=datetime.utcnow())
    kind = StringField()

    # pseudo starts
    &lt;if self.kind == "running"&gt;
    settings = EmbeddedDocumentField('RunningSettings')

    &lt;if self.kind == "weight_lifting"&gt;
    settings = EmbeddedDocumentField('WeightLiftingSettings')
</code></pre>

<p>My issue is that every time I <code>.save()</code> the object, I'm not sure how this can work. Maybe it is too weird or complicated to begin with? I'm open to suggestions. </p>