Updated docs and Authors list re: db_alias
This commit is contained in:
parent
112e921ce2
commit
e7bcb5e366
1
AUTHORS
1
AUTHORS
@ -86,4 +86,5 @@ that much better:
|
||||
* jwilder
|
||||
* Joe Shaw
|
||||
* Adam Flynn
|
||||
* Ankhbayar
|
||||
* Jan Schrewe
|
||||
|
@ -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
|
||||
|
@ -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"}
|
||||
|
Loading…
x
Reference in New Issue
Block a user