Added indexes and Django use to docs

This commit is contained in:
Harry Marr
2010-01-07 23:54:57 +00:00
parent ef5815e4a5
commit 960aea2fd4
3 changed files with 50 additions and 0 deletions

View File

@@ -168,6 +168,22 @@ The following example shows a :class:`Log` document that will be limited to
ip_address = StringField()
meta = {'max_documents': 1000, 'max_size': 2000000}
Indexes
-------
You can specify indexes on collections to make querying faster. This is done
by creating a list of index specifications called :attr:`indexes` in the
:attr:`~Document.meta` dictionary, where an index specification may either be
a single field name, or a tuple containing multiple field names. A direction
may be specified on fields by prefixing the field name with a **+** or a **-**
sign. Note that direction only matters on multi-field indexes. ::
class Page(Document):
title = StringField()
rating = StringField()
meta = {
'indexes': ['title', ('title', '-rating')]
}
Document inheritance
--------------------
To create a specialised type of a :class:`~mongoengine.Document` you have