pub struct Database { /* private fields */ }
Expand description
Database Type
Contains a connection pool and a migration manager
Implementations§
Source§impl Database
impl Database
Sourcepub async fn new(
name: impl Into<String>,
user: impl Into<String>,
password: impl Into<String>,
) -> Result<Self, DatabaseError>
pub async fn new( name: impl Into<String>, user: impl Into<String>, password: impl Into<String>, ) -> Result<Self, DatabaseError>
Create a new database
Sourcepub async fn with_host(
host: impl Into<String>,
name: impl Into<String>,
user: impl Into<String>,
password: impl Into<String>,
) -> Result<Self, DatabaseError>
pub async fn with_host( host: impl Into<String>, name: impl Into<String>, user: impl Into<String>, password: impl Into<String>, ) -> Result<Self, DatabaseError>
Create a new database with a host
Sourcepub async fn with_cfg(cfg: Config) -> Result<Self, DatabaseError>
pub async fn with_cfg(cfg: Config) -> Result<Self, DatabaseError>
Create a new database with a custom configuration.
Sourcepub async fn get(&self) -> Result<ConnectionOwned, DatabaseError>
pub async fn get(&self) -> Result<ConnectionOwned, DatabaseError>
Get a connection from the pool.
Sourcepub fn migrations(&self) -> Migrations
pub fn migrations(&self) -> Migrations
Get the migrations.
Sourcepub fn table_owned<T>(&self, name: &'static str) -> TableOwned<T>where
T: TableTemplate,
pub fn table_owned<T>(&self, name: &'static str) -> TableOwned<T>where
T: TableTemplate,
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
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