Trait geekorm_core::backends::GeekConnector

source ·
pub trait GeekConnector{
    type Connection;
    type Row;
    type Rows;

    // Provided methods
    async fn create_table(connection: &Self::Connection) -> Result<(), Error> { ... }
    async fn row_count(
        connection: &Self::Connection,
        query: Query,
    ) -> Result<i64, Error> { ... }
    async fn execute(
        connection: &Self::Connection,
        query: Query,
    ) -> Result<(), Error> { ... }
    async fn query(
        connection: &Self::Connection,
        query: Query,
    ) -> Result<Self::Rows, Error> { ... }
    async fn query_first(
        connection: &Self::Connection,
        query: Query,
    ) -> Result<Self::Row, Error> { ... }
    async fn query_raw(
        connection: &Self::Connection,
        query: Query,
    ) -> Result<Vec<HashMap<String, Value>>, Error> { ... }
}
Expand description

This trait is used to define the connection to the database.

The main focus of this trait is to provide a way to connect to the database for any Table that implements it.

Required Associated Types§

source

type Connection

The connection type

source

type Row

The row

source

type Rows

The rows to return type

Provided Methods§

source

async fn create_table(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( connection: &Self::Connection, query: Query, ) -> Result<(), Error>

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

source

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

Query the database with an active Connection and Query

source

async fn query_first( connection: &Self::Connection, query: Query, ) -> Result<Self::Row, 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§