Database

Trait Database 

Source
pub trait Database:
    Send
    + Sync
    + Debug {
    // Required methods
    fn db_type(&self) -> DatabaseType;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn query<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<AnyRow>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn query_one<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<AnyRow>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn ping<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn begin_transaction<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<DbTransaction>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn execute_query<'q, 'life0, 'async_trait>(
        &'life0 self,
        query: Query<'q, Any, AnyArguments<'q>>,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'q: 'async_trait,
             'life0: 'async_trait;
    fn fetch_all<'q, 'life0, 'async_trait>(
        &'life0 self,
        query: Query<'q, Any, AnyArguments<'q>>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<AnyRow>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'q: 'async_trait,
             'life0: 'async_trait;
    fn fetch_one<'q, 'life0, 'async_trait>(
        &'life0 self,
        query: Query<'q, Any, AnyArguments<'q>>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<AnyRow>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'q: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Common database trait

Required Methods§

Source

fn db_type(&self) -> DatabaseType

Get the database type

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute a query

Source

fn query<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<AnyRow>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Query multiple rows

Source

fn query_one<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<AnyRow>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Query one row

Source

fn ping<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check health

Source

fn begin_transaction<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<DbTransaction>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Begin a transaction

Source

fn execute_query<'q, 'life0, 'async_trait>( &'life0 self, query: Query<'q, Any, AnyArguments<'q>>, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'q: 'async_trait, 'life0: 'async_trait,

Execute a sqlx Query

Source

fn fetch_all<'q, 'life0, 'async_trait>( &'life0 self, query: Query<'q, Any, AnyArguments<'q>>, ) -> Pin<Box<dyn Future<Output = Result<Vec<AnyRow>>> + Send + 'async_trait>>
where Self: 'async_trait, 'q: 'async_trait, 'life0: 'async_trait,

Fetch all from a sqlx Query

Source

fn fetch_one<'q, 'life0, 'async_trait>( &'life0 self, query: Query<'q, Any, AnyArguments<'q>>, ) -> Pin<Box<dyn Future<Output = Result<Option<AnyRow>>> + Send + 'async_trait>>
where Self: 'async_trait, 'q: 'async_trait, 'life0: 'async_trait,

Fetch one from a sqlx Query

Implementors§