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§
sourcetype Connection
type Connection
Native Connection
Provided Methods§
sourceasync fn create_table<T>(connection: &Self::Connection) -> Result<(), Error>
async fn create_table<T>(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<T>(
connection: &Self::Connection,
query: Query,
) -> Result<(), Error>where
T: DeserializeOwned,
async fn execute<T>(
connection: &Self::Connection,
query: Query,
) -> Result<(), Error>where
T: DeserializeOwned,
Execute a query on the database and do not return any rows
sourceasync fn query<T>(
connection: &Self::Connection,
query: Query,
) -> Result<Vec<T>, Error>where
T: DeserializeOwned,
async fn query<T>(
connection: &Self::Connection,
query: Query,
) -> Result<Vec<T>, Error>where
T: DeserializeOwned,
Query the database with an active Connection and Query
sourceasync fn query_first<T>(
connection: &Self::Connection,
query: Query,
) -> Result<T, Error>where
T: DeserializeOwned,
async fn query_first<T>(
connection: &Self::Connection,
query: Query,
) -> Result<T, Error>where
T: DeserializeOwned,
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.