Updated Docs and bumped version

Hopefully nearer 0.6
closes #368
This commit is contained in:
Ross Lawley 2011-12-02 08:14:25 -08:00
parent e9d7353294
commit 9bfc838029
4 changed files with 48 additions and 22 deletions

View File

@ -35,13 +35,23 @@ already exist, then any changes will be updated atomically. For example::
* ``list_field.pop(0)`` - *sets* the resulting list * ``list_field.pop(0)`` - *sets* the resulting list
* ``del(list_field)`` - *unsets* whole list * ``del(list_field)`` - *unsets* whole list
To delete a document, call the :meth:`~mongoengine.Document.delete` method.
Note that this will only work if the document exists in the database and has a
valide :attr:`id`.
.. seealso:: .. seealso::
:ref:`guide-atomic-updates` :ref:`guide-atomic-updates`
Cascading Saves
---------------
If your document contains :class:`~mongoengine.ReferenceField` or
:class:`~mongoengine.GenericReferenceField` objects, then by default the
:meth:`~mongoengine.Document.save` method will automatically save any changes to
those objects as well. If this is not desired passing :attr:`cascade` as False
to the save method turns this feature off.
Deleting documents
------------------
To delete a document, call the :meth:`~mongoengine.Document.delete` method.
Note that this will only work if the document exists in the database and has a
valid :attr:`id`.
Document IDs Document IDs
============ ============
Each document in the database has a unique id. This may be accessed through the Each document in the database has a unique id. This may be accessed through the

View File

@ -195,22 +195,6 @@ to be created::
>>> a.name == b.name and a.age == b.age >>> a.name == b.name and a.age == b.age
True True
Dereferencing results
---------------------
When iterating the results of :class:`~mongoengine.ListField` or
:class:`~mongoengine.DictField` we automatically dereference any
:class:`~pymongo.dbref.DBRef` objects as efficiently as possible, reducing the
number the queries to mongo.
There are times when that efficiency is not enough, documents that have
:class:`~mongoengine.ReferenceField` objects or
:class:`~mongoengine.GenericReferenceField` objects at the top level are
expensive as the number of queries to MongoDB can quickly rise.
To limit the number of queries use
:func:`~mongoengine.queryset.QuerySet.select_related` which converts the
QuerySet to a list and dereferences as efficiently as possible.
Default Document queries Default Document queries
======================== ========================
By default, the objects :attr:`~mongoengine.Document.objects` attribute on a By default, the objects :attr:`~mongoengine.Document.objects` attribute on a
@ -313,8 +297,16 @@ would be generating "tag-clouds"::
from operator import itemgetter from operator import itemgetter
top_tags = sorted(tag_freqs.items(), key=itemgetter(1), reverse=True)[:10] top_tags = sorted(tag_freqs.items(), key=itemgetter(1), reverse=True)[:10]
Query efficiency and performance
================================
There are a couple of methods to improve efficiency when querying, reducing the
information returned by the query or efficient dereferencing .
Retrieving a subset of fields Retrieving a subset of fields
============================= -----------------------------
Sometimes a subset of fields on a :class:`~mongoengine.Document` is required, Sometimes a subset of fields on a :class:`~mongoengine.Document` is required,
and for efficiency only these should be retrieved from the database. This issue and for efficiency only these should be retrieved from the database. This issue
is especially important for MongoDB, as fields may often be extremely large is especially important for MongoDB, as fields may often be extremely large
@ -347,6 +339,27 @@ will be given::
If you later need the missing fields, just call If you later need the missing fields, just call
:meth:`~mongoengine.Document.reload` on your document. :meth:`~mongoengine.Document.reload` on your document.
Getting related data
--------------------
When iterating the results of :class:`~mongoengine.ListField` or
:class:`~mongoengine.DictField` we automatically dereference any
:class:`~pymongo.dbref.DBRef` objects as efficiently as possible, reducing the
number the queries to mongo.
There are times when that efficiency is not enough, documents that have
:class:`~mongoengine.ReferenceField` objects or
:class:`~mongoengine.GenericReferenceField` objects at the top level are
expensive as the number of queries to MongoDB can quickly rise.
To limit the number of queries use
:func:`~mongoengine.queryset.QuerySet.select_related` which converts the
QuerySet to a list and dereferences as efficiently as possible. By default
:func:`~mongoengine.queryset.QuerySet.select_related` only dereferences any
references to the depth of 1 level. If you have more complicated documents and
want to dereference more of the object at once then increasing the :attr:`max_depth`
will dereference more levels of the document.
Advanced queries Advanced queries
================ ================
Sometimes calling a :class:`~mongoengine.queryset.QuerySet` object with keyword Sometimes calling a :class:`~mongoengine.queryset.QuerySet` object with keyword

View File

@ -18,6 +18,9 @@ MongoDB. To install it, simply run
:doc:`apireference` :doc:`apireference`
The complete API documentation. The complete API documentation.
:doc:`upgrade`
The Upgrade guide.
:doc:`django` :doc:`django`
Using MongoEngine and Django Using MongoEngine and Django

View File

@ -14,7 +14,7 @@ __all__ = (document.__all__ + fields.__all__ + connection.__all__ +
__author__ = 'Harry Marr' __author__ = 'Harry Marr'
VERSION = (0, 5, 2) VERSION = (0, 5, 3)
def get_version(): def get_version():