pub trait GeekConnector<'a, C>where
C: GeekConnection<Connection = C> + 'a,
Self: Sized + TableBuilder + QueryBuilderTrait + Serialize + DeserializeOwned,{
Show 14 methods
// Required methods
async fn save(&mut self, connection: &'a C) -> Result<(), Error>;
async fn fetch(&mut self, connection: &'a C) -> Result<(), Error>;
async fn fetch_or_create(&mut self, connection: &'a C) -> Result<(), Error>;
// Provided methods
async fn query(connection: &'a C, query: Query) -> Result<Vec<Self>, Error> { ... }
async fn query_first(connection: &'a C, query: Query) -> Result<Self, Error> { ... }
async fn execute(connection: &'a C, query: Query) -> Result<(), Error> { ... }
async fn create_table(connection: &'a C) -> Result<(), Error> { ... }
async fn row_count(connection: &'a C, query: Query) -> Result<i64, Error> { ... }
async fn total(connection: &'a C) -> Result<i64, Error> { ... }
async fn update(&mut self, connection: &'a C) -> Result<(), Error> { ... }
async fn delete(&self, connection: &'a C) -> Result<(), Error> { ... }
async fn fetch_all(connection: &'a C) -> Result<Vec<Self>, Error> { ... }
async fn first(connection: &'a C) -> Result<Self, Error>
where Self: TablePrimaryKey { ... }
async fn last(connection: &'a C) -> Result<Self, Error>
where Self: TablePrimaryKey { ... }
}
Expand description
GeekConnection is the trait used for models to interact with the database.
This trait is used to define the methods that are used to interact with the database.
Required Methods§
Sourceasync fn save(&mut self, connection: &'a C) -> Result<(), Error>
async fn save(&mut self, connection: &'a C) -> Result<(), Error>
Save the current object to the database
Provided Methods§
Sourceasync fn query(connection: &'a C, query: Query) -> Result<Vec<Self>, Error>
async fn query(connection: &'a C, query: Query) -> Result<Vec<Self>, Error>
Query the database with an active Connection and Query
Sourceasync fn query_first(connection: &'a C, query: Query) -> Result<Self, Error>
async fn query_first(connection: &'a C, query: Query) -> Result<Self, Error>
Query the first row from the database with an active Connection and Query
Sourceasync fn execute(connection: &'a C, query: Query) -> Result<(), Error>
async fn execute(connection: &'a C, query: Query) -> Result<(), Error>
Execute a query on the database and do not return any rows
Sourceasync fn row_count(connection: &'a C, query: Query) -> Result<i64, Error>
async fn row_count(connection: &'a C, query: Query) -> Result<i64, Error>
Count the number of rows based on a Query
Sourceasync fn total(connection: &'a C) -> Result<i64, Error>
async fn total(connection: &'a C) -> Result<i64, Error>
Count the total number of rows in the table
Sourceasync fn update(&mut self, connection: &'a C) -> Result<(), Error>
async fn update(&mut self, connection: &'a C) -> Result<(), Error>
Update the current object in the database
Sourceasync fn delete(&self, connection: &'a C) -> Result<(), Error>
async fn delete(&self, connection: &'a C) -> Result<(), Error>
Delete the current object from the database
Sourceasync fn fetch_all(connection: &'a C) -> Result<Vec<Self>, Error>
async fn fetch_all(connection: &'a C) -> Result<Vec<Self>, Error>
Fetch all rows from the database
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.