Updated docs and Authors list re: db_alias

This commit is contained in:
Ross Lawley 2011-12-07 01:46:11 -08:00
parent 112e921ce2
commit e7bcb5e366
3 changed files with 23 additions and 0 deletions

View File

@ -86,4 +86,5 @@ that much better:
* jwilder
* Joe Shaw
* Adam Flynn
* Ankhbayar
* Jan Schrewe

View File

@ -5,6 +5,7 @@ Changelog
Changes in dev
==============
- Added db_alias support to individual documents
- Fixed GridFS documents can now be pickled
- Added Now raises an InvalidDocumentError when declaring multiple fields with the same db_field
- Added InvalidQueryError when calling with_id with a filter

View File

@ -30,3 +30,24 @@ for the connection - if no `alias` is provided then "default" is used.
In the background this uses :func:`~mongoengine.register_connection` to
store the data and you can register all aliases up front if required.
Individual documents can also support multiple databases by providing a
`db_alias` in their meta data. This allows :class:`~pymongo.dbref.DBRef` objects
to point across databases and collections. Below is an example schema, using
3 different databases to store data::
class User(Document):
name = StringField()
meta = {"db_alias": "user-db"}
class Book(Document):
name = StringField()
meta = {"db_alias": "book-db"}
class AuthorBooks(Document):
author = ReferenceField(User)
book = ReferenceField(Book)
meta = {"db_alias": "users-books-db"}