class documentation

Base class for documents that are stored in a MongoDB collection.

The ID of a document is automatically populated when it is added to the database, and the ID of a document is None if it has not been added to the database.

Method __init__ Undocumented
Method copy Returns a deep copy of the document.
Method copy_with_new_id Undocumented
Method reload Reloads the document from the database.
Method save Saves the document to the database.
Class Variable meta Undocumented
Instance Variable id the ID of the document, or None if it has not been added to the database
Instance Variable last_loaded_at Undocumented
Instance Variable last_modified_at Undocumented
Class Method _doc_name Undocumented
Method _deferred_updates Undocumented
Method _do_updates Undocumented
Method _insert Undocumented
Method _parse_changed_fields Undocumented
Method _parse_db_path Undocumented
Method _save Undocumented
Method _update Undocumented
Method _update_last_loaded_at Undocumented
Method _validate Undocumented
Method _validate_updates Undocumented
Instance Variable _changed_fields Undocumented
Instance Variable _created Undocumented

Inherited from BaseDocument:

Method __eq__ Undocumented
Property in_db Whether the document has been inserted into the database.
Method _get_repr_fields Returns an ordered tuple of field names that should be included in the repr of the document.

Inherited from MongoEngineBaseDocument (via BaseDocument):

Class Method from_dict Loads the document from a BSON/JSON dictionary.
Method __deepcopy__ Undocumented
Method __delattr__ Undocumented
Method __delitem__ Undocumented
Method clear_field Clears the field from the document.
Method field_to_mongo Undocumented
Method field_to_python Undocumented
Method get_field Gets the field of the document.
Method has_field Determines whether the document has a field of the given name.
Method set_field Sets the value of a field of the document.
Method to_dict Serializes this document to a BSON/JSON dictionary.
Property field_names An ordered tuple of the public fields of this document.
Method _get_field Undocumented
Method _get_field_names Returns an ordered tuple of field names of this document.
Method _to_db_fields Undocumented
Instance Variable _fields_ordered Undocumented

Inherited from SerializableDocument (via BaseDocument, MongoEngineBaseDocument):

Class Method from_json Loads the document from a JSON string.
Method __repr__ Undocumented
Method __str__ Undocumented
Method fancy_repr Generates a customizable string representation of the document.
Method iter_fields Returns an iterator over the (name, value) pairs of the public fields of the document.
Method merge Merges the contents of the given document into this document.
Method to_json Serializes the document to a JSON string.
def __init__(self, **kwargs): (source)
def copy(self, new_id=False): (source)

Returns a deep copy of the document.

Parameters
new_id:Falsewhether to generate a new ID for the copied document. By default, the ID is left as None and will be automatically populated when the document is added to the database
def copy_with_new_id(self): (source)

Undocumented

def reload(self, *fields, **kwargs): (source)

Reloads the document from the database.

Parameters
*fieldsan optional args list of specific fields to reload
**kwargsUndocumented
def save(self, upsert=False, validate=True, safe=False, **kwargs): (source)

Saves the document to the database.

If the document already exists, it will be updated, otherwise it will be created.

Parameters
upsert:Falsewhether to insert the document if it has an id populated but no document with that ID exists in the database
validate:Truewhether to validate the document
safe:Falsewhether to reload() the document before raising any errors
**kwargsUndocumented
Returns
self

the ID of the document, or None if it has not been added to the database

@classmethod
def _doc_name(cls): (source)

Undocumented

def _deferred_updates(self, _id, updates, upsert): (source)

Undocumented

def _do_updates(self, _id, updates, upsert): (source)

Undocumented

def _insert(self, doc, deferred=False): (source)

Undocumented

def _parse_changed_fields(self, db_paths): (source)

Undocumented

def _parse_db_path(self, db_path, roots, paths): (source)

Undocumented

def _save(self, deferred=False, upsert=False, validate=True, clean=True, enforce_read_only=True, **kwargs): (source)

Undocumented

def _update(self, _id, updates, deferred=False, upsert=False, virtual=False, **kwargs): (source)

Undocumented

def _update_last_loaded_at(self): (source)

Undocumented

def _validate(self, fields=None, clean=True): (source)

Undocumented

def _validate_updates(self, roots, paths, clean=True, enforce_read_only=True): (source)

Undocumented

_changed_fields: list = (source)

Undocumented

_created: bool = (source)

Undocumented