I am trying to query my database. Some records currently have extra fields that are not included in my model schema (by error, but I want to handle these cases). When I try to q
You can extend from mon.DynamicDocument.
class AF(mon.DynamicDocument):
meta = {
'collection': 'af'
}
user_id = mon.StringField(db_field='customer_user_id')
You can see from the document. A Dynamic Document class is allowing flexible, expandable and uncontrolled schemas.
For ignoring this error when having extra fields while data loading, set strict
to False
in your meta dictionary.
class User(Document):
email = StringField(required=True, unique=True)
password = StringField()
meta = {'strict': False}
I think you want skip schema validation, so when you save your document
document_name.save(validate=False)
I believe you want to use a DynamicDocument instead of a Document when defining your model and that will allow extra fields in the db schema to be ignored.