Trait geekorm_core::backends::GeekConnector
source · pub trait GeekConnector{
Show 13 methods
// Required methods
async fn save<'a, T>(
&mut self,
connection: impl Into<&'a T>,
) -> Result<(), Error>
where T: GeekConnection<Connection = T> + 'a;
async fn fetch<'a, T>(
&mut self,
connection: impl Into<&'a T>,
) -> Result<(), Error>
where T: GeekConnection<Connection = T> + 'a;
async fn fetch_or_create<'a, T>(
&mut self,
connection: impl Into<&'a T>,
) -> Result<(), Error>
where T: GeekConnection<Connection = T> + 'a;
// Provided methods
async fn query<'a, T>(
connection: impl Into<&'a T>,
query: Query,
) -> Result<Vec<Self>, Error>
where T: GeekConnection<Connection = T> + 'a { ... }
async fn query_first<'a, T>(
connection: impl Into<&'a T>,
query: Query,
) -> Result<Self, Error>
where T: GeekConnection<Connection = T> + 'a { ... }
async fn execute<'a, T>(
connection: impl Into<&'a T>,
query: Query,
) -> Result<(), Error>
where T: GeekConnection<Connection = T> + 'a { ... }
async fn create_table<'a, T>(
connection: impl Into<&'a T>,
) -> Result<(), Error>
where T: GeekConnection<Connection = T> + 'a,
Self: Serialize { ... }
async fn row_count<'a, T>(
connection: impl Into<&'a T>,
query: Query,
) -> Result<i64, Error>
where T: GeekConnection<Connection = T> + 'a { ... }
async fn update<'a, T>(
&self,
connection: impl Into<&'a T>,
) -> Result<(), Error>
where T: GeekConnection<Connection = T> + 'a { ... }
async fn delete<'a, T>(
&self,
connection: impl Into<&'a T>,
) -> Result<(), Error>
where T: GeekConnection + 'a { ... }
async fn fetch_all<'a, T>(
connection: impl Into<&'a T>,
) -> Result<Vec<Self>, Error>
where T: GeekConnection<Connection = T> + 'a { ... }
async fn first<'a, T>(connection: impl Into<&'a T>) -> Result<Self, Error>
where T: GeekConnection<Connection = T> + 'a,
Self: TablePrimaryKey { ... }
async fn last<'a, T>(connection: impl Into<&'a T>) -> Result<Self, Error>
where T: GeekConnection<Connection = T> + 'a,
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<'a, T>(
&mut self,
connection: impl Into<&'a T>,
) -> Result<(), Error>where
T: GeekConnection<Connection = T> + 'a,
async fn save<'a, T>(
&mut self,
connection: impl Into<&'a T>,
) -> Result<(), Error>where
T: GeekConnection<Connection = T> + 'a,
Save the current object to the database
sourceasync fn fetch<'a, T>(
&mut self,
connection: impl Into<&'a T>,
) -> Result<(), Error>where
T: GeekConnection<Connection = T> + 'a,
async fn fetch<'a, T>(
&mut self,
connection: impl Into<&'a T>,
) -> Result<(), Error>where
T: GeekConnection<Connection = T> + 'a,
Fetches all of the foreign key values for the current object
sourceasync fn fetch_or_create<'a, T>(
&mut self,
connection: impl Into<&'a T>,
) -> Result<(), Error>where
T: GeekConnection<Connection = T> + 'a,
async fn fetch_or_create<'a, T>(
&mut self,
connection: impl Into<&'a T>,
) -> Result<(), Error>where
T: GeekConnection<Connection = T> + 'a,
Fetch or create a row in the database
Provided Methods§
sourceasync fn query<'a, T>(
connection: impl Into<&'a T>,
query: Query,
) -> Result<Vec<Self>, Error>where
T: GeekConnection<Connection = T> + 'a,
async fn query<'a, T>(
connection: impl Into<&'a T>,
query: Query,
) -> Result<Vec<Self>, Error>where
T: GeekConnection<Connection = T> + 'a,
Query the database with an active Connection and Query
sourceasync fn query_first<'a, T>(
connection: impl Into<&'a T>,
query: Query,
) -> Result<Self, Error>where
T: GeekConnection<Connection = T> + 'a,
async fn query_first<'a, T>(
connection: impl Into<&'a T>,
query: Query,
) -> Result<Self, Error>where
T: GeekConnection<Connection = T> + 'a,
Query the first row from the database with an active Connection and Query
sourceasync fn execute<'a, T>(
connection: impl Into<&'a T>,
query: Query,
) -> Result<(), Error>where
T: GeekConnection<Connection = T> + 'a,
async fn execute<'a, T>(
connection: impl Into<&'a T>,
query: Query,
) -> Result<(), Error>where
T: GeekConnection<Connection = T> + 'a,
Execute a query on the database and do not return any rows
sourceasync fn create_table<'a, T>(connection: impl Into<&'a T>) -> Result<(), Error>where
T: GeekConnection<Connection = T> + 'a,
Self: Serialize,
async fn create_table<'a, T>(connection: impl Into<&'a T>) -> Result<(), Error>where
T: GeekConnection<Connection = T> + 'a,
Self: Serialize,
Create a table in the database
sourceasync fn row_count<'a, T>(
connection: impl Into<&'a T>,
query: Query,
) -> Result<i64, Error>where
T: GeekConnection<Connection = T> + 'a,
async fn row_count<'a, T>(
connection: impl Into<&'a T>,
query: Query,
) -> Result<i64, Error>where
T: GeekConnection<Connection = T> + 'a,
Count the number of rows based on a Query
sourceasync fn update<'a, T>(&self, connection: impl Into<&'a T>) -> Result<(), Error>where
T: GeekConnection<Connection = T> + 'a,
async fn update<'a, T>(&self, connection: impl Into<&'a T>) -> Result<(), Error>where
T: GeekConnection<Connection = T> + 'a,
Update the current object in the database
sourceasync fn delete<'a, T>(&self, connection: impl Into<&'a T>) -> Result<(), Error>where
T: GeekConnection + 'a,
async fn delete<'a, T>(&self, connection: impl Into<&'a T>) -> Result<(), Error>where
T: GeekConnection + 'a,
Delete the current object from the database
sourceasync fn fetch_all<'a, T>(
connection: impl Into<&'a T>,
) -> Result<Vec<Self>, Error>where
T: GeekConnection<Connection = T> + 'a,
async fn fetch_all<'a, T>(
connection: impl Into<&'a T>,
) -> Result<Vec<Self>, Error>where
T: GeekConnection<Connection = T> + 'a,
Fetch all rows from the database
sourceasync fn first<'a, T>(connection: impl Into<&'a T>) -> Result<Self, Error>where
T: GeekConnection<Connection = T> + 'a,
Self: TablePrimaryKey,
async fn first<'a, T>(connection: impl Into<&'a T>) -> Result<Self, Error>where
T: GeekConnection<Connection = T> + 'a,
Self: TablePrimaryKey,
Fetch the first row from the database (based on the primary key)
sourceasync fn last<'a, T>(connection: impl Into<&'a T>) -> Result<Self, Error>where
T: GeekConnection<Connection = T> + 'a,
Self: TablePrimaryKey,
async fn last<'a, T>(connection: impl Into<&'a T>) -> Result<Self, Error>where
T: GeekConnection<Connection = T> + 'a,
Self: TablePrimaryKey,
Fetch last row from the database (based on the primary key)