Skip to main content

DatabaseRouter

Trait DatabaseRouter 

Source
pub trait DatabaseRouter:
    Send
    + Sync
    + 'static {
    // Provided methods
    fn db_for_read(&self, model: &ModelMeta) -> Option<&str> { ... }
    fn db_for_write(&self, model: &ModelMeta) -> Option<&str> { ... }
    fn allow_migrate(&self, alias: &str, model: &ModelMeta) -> bool { ... }
}
Expand description

Chooses the database alias for a model. Every hook has a neutral default.

Provided Methods§

Source

fn db_for_read(&self, model: &ModelMeta) -> Option<&str>

Alias to read model from; None means the default database.

Source

fn db_for_write(&self, model: &ModelMeta) -> Option<&str>

Alias to write model to; None means the default database.

Source

fn allow_migrate(&self, alias: &str, model: &ModelMeta) -> bool

Whether migrations may create model’s table on database alias.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§