mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

Confused about the documentation

Open kietheros opened this issue 1 year ago • 2 comments

I am confused about this line in mongoengine docs

If you use Document and the database contains data that isn’t defined then that data will be stored in the document._data dictionary.

I tested with Document, when loading a document which has a field not defined in schema, mongoengine raises mongoengine.errors.FieldDoesNotExist

kietheros avatar Sep 07 '24 10:09 kietheros

Good catch, it should be "If you use DynamicDocument" instead

bagerard avatar Sep 08 '24 21:09 bagerard

@bagerard As far as I understand, with DynamicDocument, fields that do not exist in the schema still become attributes of the model instance. I think that this sentence wants to mention Document with strict is set to False.

kietheros avatar Sep 09 '24 03:09 kietheros