geekorm_core::backends

Trait GeekConnection

source
pub trait GeekConnection {
    type Connection;

    // Provided methods
    async fn create_table<T>(connection: &Self::Connection) -> Result<(), Error>
       where T: TableBuilder + QueryBuilderTrait + Sized + Serialize + DeserializeOwned { ... }
    async fn row_count(
        connection: &Self::Connection,
        query: Query,
    ) -> Result<i64, Error> { ... }
    async fn execute<T>(
        connection: &Self::Connection,
        query: Query,
    ) -> Result<(), Error>
       where T: DeserializeOwned { ... }
    async fn query<T>(
        connection: &Self::Connection,
        query: Query,
    ) -> Result<Vec<T>, Error>
       where T: DeserializeOwned { ... }
    async fn query_first<T>(
        connection: &Self::Connection,
        query: Query,
    ) -> Result<T, Error>
       where T: DeserializeOwned { ... }
    async fn query_raw(
        connection: &Self::Connection,
        query: Query,
    ) -> Result<Vec<HashMap<String, Value>>, Error> { ... }
}
Expand description

GeekConnection is the trait that all backends must implement to be able to interact with the database.

Required Associated Types§

source

type Connection

Native Connection

Provided Methods§

source

async fn create_table<T>(connection: &Self::Connection) -> Result<(), Error>

Create a table in the database

source

async fn row_count( connection: &Self::Connection, query: Query, ) -> Result<i64, Error>

Run a SELECT Count query on the database and return the number of rows

source

async fn execute<T>( connection: &Self::Connection, query: Query, ) -> Result<(), Error>

Execute a query on the database and do not return any rows

source

async fn query<T>( connection: &Self::Connection, query: Query, ) -> Result<Vec<T>, Error>

Query the database with an active Connection and Query

source

async fn query_first<T>( connection: &Self::Connection, query: Query, ) -> Result<T, Error>

Query the database with an active Connection and Query and return the first row.

Note: Make sure the query is limited to 1 row to avoid retrieving multiple rows and only using the first one.

source

async fn query_raw( connection: &Self::Connection, query: Query, ) -> Result<Vec<HashMap<String, Value>>, Error>

Query the database with an active Connection and Query and return a list of GeekORM Values.

Object Safety§

This trait is not object safe.

Implementors§