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(
connection: &Self::Connection,
query: Query,
) -> Result<(), Error> { ... }
async fn batch(
connection: &Self::Connection,
query: Query,
) -> Result<(), Error> { ... }
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> { ... }
async fn table_names(
connection: &Self::Connection,
) -> Result<Vec<String>, Error> { ... }
async fn pragma_info(
connection: &Self::Connection,
table: &str,
) -> Result<Vec<TableInfo>, 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(
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 batch(connection: &Self::Connection, query: Query) -> Result<(), Error>
async fn batch(connection: &Self::Connection, query: Query) -> Result<(), Error>
Execute a batch 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.
Sourceasync fn query_raw(
connection: &Self::Connection,
query: Query,
) -> Result<Vec<HashMap<String, Value>>, Error>
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.
Sourceasync fn table_names(
connection: &Self::Connection,
) -> Result<Vec<String>, Error>
async fn table_names( connection: &Self::Connection, ) -> Result<Vec<String>, Error>
Get Table Names
Sourceasync fn pragma_info(
connection: &Self::Connection,
table: &str,
) -> Result<Vec<TableInfo>, Error>
async fn pragma_info( connection: &Self::Connection, table: &str, ) -> Result<Vec<TableInfo>, Error>
Pragma table info
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.