pub struct Database { /* private fields */ }
Expand description
Database connection and migration management
Implementations§
Source§impl Database
impl Database
Sourcepub fn new(
connection_string: &str,
) -> Result<Self, Box<dyn Error + Send + Sync>>
pub fn new( connection_string: &str, ) -> Result<Self, Box<dyn Error + Send + Sync>>
Create a new database connection and run migrations
§Arguments
connection_string
- SQLite connection string (e.g., “:memory:”, “database.db”, “file:database.db?mode=rw”)
Sourcepub fn get_connection(
&self,
) -> Result<SqliteConnection, Box<dyn Error + Send + Sync>>
pub fn get_connection( &self, ) -> Result<SqliteConnection, Box<dyn Error + Send + Sync>>
Get a new connection to the database
Sourcepub fn repository(
&self,
) -> Result<DocumentRepository, Box<dyn Error + Send + Sync>>
pub fn repository( &self, ) -> Result<DocumentRepository, Box<dyn Error + Send + Sync>>
Get a document repository with a new connection
Sourcepub fn into_repository(self) -> DocumentRepository
pub fn into_repository(self) -> DocumentRepository
Get a document repository (consumes the database) - kept for compatibility
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
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
Convert
self
to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
Convert
&self
to an expression for Diesel’s query builder. Read more