Differences between Mongomallard and Mongoengine
- All document fields are lazily evaluated, resulting in much faster object initialization time.
_datais removed due to lazy evaluation.
to_dict()can be used to convert a document to a dictionary, and
_internal_datacontains previously evaluated data.
- Field methods
to_pythonis called when converting from a MongoDB type to a document Python type only.
from_pythonis called when converting an assignment in Python to the document Python type.
to_mongois called when converting from a document Python type to a MongoDB type.
value_for_instanceis called just before returning a value in Python allowing for instance-specific transformations.
pre_save_post_validationsignals are removed to ensure fast object initialization.
DecimalFieldis removed since there is no corresponding MongoDB type
LongFieldis removed since it is equivalent with
SafeReferenceFieldwhich returns None if the reference does not exist.
SafeReferenceListFieldwhich doesn't return references that don't exist.
- Accessing a
ListField(ReferenceField)doesn't automatically dereference all objects since they are lazily evaluated. A
SafeReferenceListFieldmay be used instead.
- Accessing a related object's id doesn't fetch the object from the database, e.g.
book.author.idwhere author is a
ReferenceFieldwill not make a database lookup except when using a
SafeReferenceField. When inheritance is allowed, a proxy object will be returned, otherwise a lazy object from the referenced document class will be returned.
- The primary key is only stored as
_idin the database and is referenced in Python as
pkor as the name of the primary key field.
- Saves are not cascaded by default.
full=Truekeyword argument to force saving all model fields.
_changed_fieldsreturns a set of field names (not db field names)
EmailFieldemail regex to be more compatible
- Assigning invalid types (e.g. an invalid string to
IntField) raises immediately a
order_by()without an argument resets the ordering (no ordering will be applied)
Untested / not implemented yet:
- Dynamic documents /
DynamicField, dynamic addition/deletion of fields
- Field display name methods
- Pickling documents
- All Geo fields