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§
sourcetype Connection
type Connection
The connection type
Provided Methods§
sourceasync fn create_table(connection: &Self::Connection) -> Result<(), Error>
async fn create_table(connection: &Self::Connection) -> Result<(), Error>
Create a table in the database
sourceasync fn row_count(
connection: &Self::Connection,
query: Query,
) -> Result<i64, Error>
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
sourceasync fn execute(
connection: &Self::Connection,
query: Query,
) -> Result<(), Error>
async fn execute( connection: &Self::Connection, query: Query, ) -> Result<(), Error>
Execute a query on the database and do not return any rows
sourceasync fn query(
connection: &Self::Connection,
query: Query,
) -> Result<Self::Rows, Error>
async fn query( connection: &Self::Connection, query: Query, ) -> Result<Self::Rows, Error>
Query the database with an active Connection and Query
sourceasync fn query_first(
connection: &Self::Connection,
query: Query,
) -> Result<Self::Row, Error>
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.
Object Safety§
This trait is not object safe.