pub struct Db { /* private fields */ }Expand description
Db
The database connection pool manager in NestForge. Provides access to one or more database connections.
Implementations§
Source§impl Db
impl Db
Sourcepub fn connect_lazy(config: DbConfig) -> Result<Self, DbError>
pub fn connect_lazy(config: DbConfig) -> Result<Self, DbError>
Connects to the database lazily (without verifying connection).
Sourcepub async fn connect_many<I>(
primary: DbConfig,
named: I,
) -> Result<Self, DbError>
pub async fn connect_many<I>( primary: DbConfig, named: I, ) -> Result<Self, DbError>
Connects to multiple databases simultaneously.
§Arguments
primary: Configuration for the primary databasenamed: Iterator of (name, config) pairs for additional databases
pub fn connect_many_lazy<I>( primary: DbConfig, named: I, ) -> Result<Self, DbError>
pub fn pool(&self) -> &AnyPool
pub fn pool_named(&self, name: &str) -> Result<&AnyPool, DbError>
pub async fn execute(&self, sql: &str) -> Result<u64, DbError>
pub async fn execute_script(&self, sql: &str) -> Result<(), DbError>
pub async fn execute_named(&self, name: &str, sql: &str) -> Result<u64, DbError>
pub async fn fetch_all<T>(&self, sql: &str) -> Result<Vec<T>, DbError>
pub async fn fetch_all_named<T>( &self, name: &str, sql: &str, ) -> Result<Vec<T>, DbError>
pub async fn begin(&self) -> Result<DbTransaction, DbError>
pub async fn begin_named(&self, name: &str) -> Result<DbTransaction, DbError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Db
impl !RefUnwindSafe for Db
impl Send for Db
impl Sync for Db
impl Unpin for Db
impl UnsafeUnpin for Db
impl !UnwindSafe for Db
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more