Essentially I’d like to be able to defined dynamic fields by using a property decorator on my MongoEngine models. Something like this:
class Model(Document):
foo = StringField()
@property
def bar(self):
return 'baz'
m = Model(foo='abc'); m.save()
Then I’d like to be able to query by the property. Something like this:
Model.objects(bar='baz')
I thought maybe DynamicDocument might provide this facility. But that doesn’t seem to work. Any suggestions? Could a custom property decorator handle this?
Properties don’t act like fields no data is stored in the database, so you cant query the database for a match.