pub struct DbReadConnection(/* private fields */);Expand description
Read pool. Multi-connection; concurrent reads enabled by WAL mode.
ConnectionTrait is implemented so SELECTs work transparently. Writes
also technically execute (sea-orm has no read-only enforcement at the
trait level), but doing so via this type defeats the purpose — write
paths must take a DbWriteConnection argument.
Clone is cheap: the inner DatabaseConnection holds an Arc over
the underlying sqlx pool, so clones share connection state.
Implementations§
Source§impl DbReadConnection
impl DbReadConnection
Sourcepub fn new(inner: DatabaseConnection) -> Self
pub fn new(inner: DatabaseConnection) -> Self
Wrap a sea-orm connection as a read pool.
Sourcepub async fn open(
db_path: &Path,
max_connections: u32,
connect_timeout: Duration,
busy_timeout: Duration,
) -> Result<Self, Error>
pub async fn open( db_path: &Path, max_connections: u32, connect_timeout: Duration, busy_timeout: Duration, ) -> Result<Self, Error>
Open a stand-alone read pool at db_path with shared PRAGMAs.
Read-only: opening a non-existent DB fails rather than creating it, so a
read consumer never authors or pre-empts the catalog owned by msb.
Sourcepub fn inner(&self) -> &DatabaseConnection
pub fn inner(&self) -> &DatabaseConnection
Borrow the underlying sea-orm connection.
Trait Implementations§
Source§impl Clone for DbReadConnection
impl Clone for DbReadConnection
Source§fn clone(&self) -> DbReadConnection
fn clone(&self) -> DbReadConnection
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl ConnectionTrait for DbReadConnection
impl ConnectionTrait for DbReadConnection
Source§fn get_database_backend(&self) -> DbBackend
fn get_database_backend(&self) -> DbBackend
Fetch the database backend as specified in DbBackend.
This depends on feature flags enabled.
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute a Statement
Source§fn execute_unprepared<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute_unprepared<'life0, 'life1, 'async_trait>(
&'life0 self,
sql: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute a unprepared Statement
Source§fn query_one<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn query_one<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute a Statement and return a query
Source§fn query_all<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn query_all<'life0, 'async_trait>(
&'life0 self,
stmt: Statement,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute a Statement and return a collection Vec<QueryResult> on success
Source§fn support_returning(&self) -> bool
fn support_returning(&self) -> bool
Check if the connection supports
RETURNING syntax on insert and updateSource§fn is_mock_connection(&self) -> bool
fn is_mock_connection(&self) -> bool
Check if the connection is a test connection for the Mock database
Auto Trait Implementations§
impl !RefUnwindSafe for DbReadConnection
impl !UnwindSafe for DbReadConnection
impl Freeze for DbReadConnection
impl Send for DbReadConnection
impl Sync for DbReadConnection
impl Unpin for DbReadConnection
impl UnsafeUnpin for DbReadConnection
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