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§

source

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

source

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

source

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§

source

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

source

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

source

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

source

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

source

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

source

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

source

async fn delete<'a, T>(&self, connection: impl Into<&'a T>) -> Result<(), Error>
where T: GeekConnection + 'a,

Delete the current object from the database

source

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

source

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)

source

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)

Object Safety§

This trait is not object safe.

Implementors§