Added no_dereference context manager (#82)
Reorganised the context_managers as well
This commit is contained in:
parent
4f70c27b56
commit
3a6dc77d36
16 changed files with 289 additions and 128 deletions
|
|
@ -75,15 +75,15 @@ Switch Database Context Manager
|
|||
===============================
|
||||
|
||||
Sometimes you might want to switch the database to query against for a class.
|
||||
The SwitchDB context manager allows you to change the database alias for a
|
||||
class eg ::
|
||||
The :class:`~mongoengine.context_managers.switch_db` context manager allows
|
||||
you to change the database alias for a class eg ::
|
||||
|
||||
from mongoengine import SwitchDB
|
||||
from mongoengine.context_managers import switch_db
|
||||
|
||||
class User(Document):
|
||||
name = StringField()
|
||||
|
||||
meta = {"db_alias": "user-db"}
|
||||
|
||||
with SwitchDB(User, 'archive-user-db') as User:
|
||||
with switch_db(User, 'archive-user-db') as User:
|
||||
User(name="Ross").save() # Saves the 'archive-user-db'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue