zino_orm

Trait Executor

Source
pub trait Executor {
    type Row;
    type QueryResult;

    // Required methods
    async fn execute(self, sql: &str) -> Result<Self::QueryResult, Error>;
    async fn execute_with<T: ToString>(
        self,
        sql: &str,
        arguments: &[T],
    ) -> Result<Self::QueryResult, Error>;
    async fn fetch(self, sql: &str) -> Result<Vec<Self::Row>, Error>;
    async fn fetch_with<T: ToString>(
        self,
        sql: &str,
        arguments: &[T],
    ) -> Result<Vec<Self::Row>, Error>;
    async fn fetch_one(self, sql: &str) -> Result<Self::Row, Error>;
    async fn fetch_optional(self, sql: &str) -> Result<Option<Self::Row>, Error>;
    async fn fetch_optional_with<T: ToString>(
        self,
        sql: &str,
        arguments: &[T],
    ) -> Result<Option<Self::Row>, Error>;
}
Expand description

Executing queries against the database.

Required Associated Types§

Source

type Row

A type for the database row.

Source

type QueryResult

A type for the query result.

Required Methods§

Source

async fn execute(self, sql: &str) -> Result<Self::QueryResult, Error>

Executes the query and return the total number of rows affected.

Source

async fn execute_with<T: ToString>( self, sql: &str, arguments: &[T], ) -> Result<Self::QueryResult, Error>

Executes the query with arguments and return the total number of rows affected.

Source

async fn fetch(self, sql: &str) -> Result<Vec<Self::Row>, Error>

Executes the query and return all the generated results.

Source

async fn fetch_with<T: ToString>( self, sql: &str, arguments: &[T], ) -> Result<Vec<Self::Row>, Error>

Executes the query with arguments and return all the generated results.

Source

async fn fetch_one(self, sql: &str) -> Result<Self::Row, Error>

Executes the query and returns exactly one row.

Source

async fn fetch_optional(self, sql: &str) -> Result<Option<Self::Row>, Error>

Executes the query and returns at most one row.

Source

async fn fetch_optional_with<T: ToString>( self, sql: &str, arguments: &[T], ) -> Result<Option<Self::Row>, Error>

Executes the query with arguments and returns at most one row.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'c> Executor for &'c Pool<DatabaseDriver>

Available on crate feature orm-sqlx only.
Source§

type Row = SqliteRow

Source§

type QueryResult = <Sqlite as Database>::QueryResult

Source§

async fn execute(self, sql: &str) -> Result<Self::QueryResult, Error>

Source§

async fn execute_with<T: ToString>( self, sql: &str, arguments: &[T], ) -> Result<Self::QueryResult, Error>

Source§

async fn fetch(self, sql: &str) -> Result<Vec<Self::Row>, Error>

Source§

async fn fetch_with<T: ToString>( self, sql: &str, arguments: &[T], ) -> Result<Vec<Self::Row>, Error>

Source§

async fn fetch_one(self, sql: &str) -> Result<Self::Row, Error>

Source§

async fn fetch_optional(self, sql: &str) -> Result<Option<Self::Row>, Error>

Source§

async fn fetch_optional_with<T: ToString>( self, sql: &str, arguments: &[T], ) -> Result<Option<Self::Row>, Error>

Implementors§

Source§

impl<'c> Executor for &'c mut DatabaseConnection

Available on crate feature orm-sqlx only.