geekorm_core::backends

Trait GeekConnector

Source
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§

Source

async fn save(&mut self, connection: &'a C) -> Result<(), Error>

Save the current object to the database

Source

async fn fetch(&mut self, connection: &'a C) -> Result<(), Error>

Fetches all of the foreign key values for the current object

Source

async fn fetch_or_create(&mut self, connection: &'a C) -> Result<(), Error>

Fetch or create a row in the database

Provided Methods§

Source

async fn query(connection: &'a C, query: Query) -> Result<Vec<Self>, Error>

Query the database with an active Connection and Query

Source

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

Source

async fn execute(connection: &'a C, query: Query) -> Result<(), Error>

Execute a query on the database and do not return any rows

Source

async fn create_table(connection: &'a C) -> Result<(), Error>

Create a table in the database

Source

async fn row_count(connection: &'a C, query: Query) -> Result<i64, Error>

Count the number of rows based on a Query

Source

async fn total(connection: &'a C) -> Result<i64, Error>

Count the total number of rows in the table

Source

async fn update(&mut self, connection: &'a C) -> Result<(), Error>

Update the current object in the database

Source

async fn delete(&self, connection: &'a C) -> Result<(), Error>

Delete the current object from the database

Source

async fn fetch_all(connection: &'a C) -> Result<Vec<Self>, Error>

Fetch all rows from the database

Source

async fn first(connection: &'a C) -> Result<Self, Error>
where Self: TablePrimaryKey,

Fetch the first row from the database (based on the primary key)

Source

async fn last(connection: &'a C) -> Result<Self, Error>
where Self: TablePrimaryKey,

Fetch last row from the database (based on the primary key)

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.

Implementors§