Added capped collections support

This commit is contained in:
Harry Marr
2010-01-04 03:33:42 +00:00
parent 0830f0b480
commit 6363b6290b
5 changed files with 97 additions and 2 deletions

View File

@@ -153,6 +153,21 @@ document class to use::
title = StringField(max_length=200, required=True)
meta = {'collection': 'cmsPage'}
Capped collections
^^^^^^^^^^^^^^^^^^
A :class:`~mongoengine.Document` may use a **Capped Collection** by specifying
:attr:`max_documents` and :attr:`max_size` in the :attr:`meta` dictionary.
:attr:`max_documents` is the maximum number of documents that is allowed to be
stored in the collection, and :attr:`max_size` is the maximum size of the
collection in bytes. If :attr:`max_size` is not specified and
:attr:`max_documents` is, :attr:`max_size` defaults to 10000000 bytes (10MB).
The following example shows a :class:`Log` document that will be limited to
1000 entries and 2MB of disk space::
class Log(Document):
ip_address = StringField()
meta = {'max_documents': 1000, 'max_size': 2000000}
Document inheritance
--------------------
To create a specialised type of a :class:`~mongoengine.Document` you have