pub struct Databases { /* private fields */ }Expand description
Implementations§
Source§impl Databases
impl Databases
Sourcepub const DEFAULT: &'static str = "default"
pub const DEFAULT: &'static str = "default"
Alias used by default_db.
Sourcepub fn with(self, alias: impl Into<String>, db: Db) -> Self
pub fn with(self, alias: impl Into<String>, db: Db) -> Self
Register db under alias (replacing an existing entry).
Sourcepub fn with_router(self, router: impl DatabaseRouter) -> Self
pub fn with_router(self, router: impl DatabaseRouter) -> Self
Route reads and writes through router (replacing a previous one).
Sourcepub fn default_db(&self) -> Option<&Db>
pub fn default_db(&self) -> Option<&Db>
Handle registered as "default".
Sourcepub fn for_read<M: Model>(&self) -> Result<&Db, OrmError>
pub fn for_read<M: Model>(&self) -> Result<&Db, OrmError>
The database M is read from: the router’s choice, else "default".
§Errors
OrmError::UnknownDatabase if the chosen alias is not registered.
Sourcepub fn for_write<M: Model>(&self) -> Result<&Db, OrmError>
pub fn for_write<M: Model>(&self) -> Result<&Db, OrmError>
The database M is written to: the router’s choice, else "default".
§Errors
OrmError::UnknownDatabase if the chosen alias is not registered.
Sourcepub fn using<M: Model>(&self, alias: &str) -> Result<QuerySet<M>, OrmError>
pub fn using<M: Model>(&self, alias: &str) -> Result<QuerySet<M>, OrmError>
Queryset over M on the database registered as alias (Django
Model.objects.using(alias)), bypassing the router.
§Errors
OrmError::UnknownDatabase if alias is not registered.
Sourcepub fn allow_migrate(&self, alias: &str, model: &ModelMeta) -> bool
pub fn allow_migrate(&self, alias: &str, model: &ModelMeta) -> bool
Whether migrations may create model on alias (true without a
router).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Databases
impl !UnwindSafe for Databases
impl Freeze for Databases
impl Send for Databases
impl Sync for Databases
impl Unpin for Databases
impl UnsafeUnpin for Databases
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more