Model

Trait Model 

Source
pub trait Model<DB>:
    Sized
    + Send
    + Sync
    + Unpin
where DB: SqlDialect + Database, for<'r> Self: FromRow<'r, DB::Row>,
{ // Required methods fn table_name() -> &'static str; fn create_table_sql() -> String; fn list_columns() -> Vec<String>; fn save<'a, 'life0, 'async_trait, E>( &'life0 mut self, executor: E, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where E: IntoExecutor<'a, DB = DB> + 'async_trait, Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait; fn update<'a, 'life0, 'async_trait, E>( &'life0 mut self, executor: E, ) -> Pin<Box<dyn Future<Output = Result<UpdateResult, Error>> + Send + 'async_trait>> where E: IntoExecutor<'a, DB = DB> + 'async_trait, Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait; fn delete<'a, 'life0, 'async_trait, E>( &'life0 mut self, executor: E, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where E: IntoExecutor<'a, DB = DB> + 'async_trait, Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait; fn has_soft_delete() -> bool; fn find_by_id<'a, 'async_trait, E>( executor: E, id: i32, ) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Error>> + Send + 'async_trait>> where E: IntoExecutor<'a, DB = DB> + 'async_trait, Self: 'async_trait, 'a: 'async_trait; // Provided methods fn eager_load<'a, 'life0, 'life1, 'async_trait, E>( _models: &'life0 mut [Self], _relation: &'life1 str, _executor: E, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where E: IntoExecutor<'a, DB = DB> + 'async_trait, Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn find<'a, E>(executor: E) -> QueryBuilder<'a, Self, DB> where E: IntoExecutor<'a, DB = DB> { ... } fn find_in_pool(pool: &Pool<DB>) -> QueryBuilder<'_, Self, DB> { ... } fn find_in_tx(conn: &mut DB::Connection) -> QueryBuilder<'_, Self, DB> { ... } }

Required Methods§

Source

fn table_name() -> &'static str

Source

fn create_table_sql() -> String

Source

fn list_columns() -> Vec<String>

Source

fn save<'a, 'life0, 'async_trait, E>( &'life0 mut self, executor: E, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where E: IntoExecutor<'a, DB = DB> + 'async_trait, Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait,

Saves the current instance to the database.

Source

fn update<'a, 'life0, 'async_trait, E>( &'life0 mut self, executor: E, ) -> Pin<Box<dyn Future<Output = Result<UpdateResult, Error>> + Send + 'async_trait>>
where E: IntoExecutor<'a, DB = DB> + 'async_trait, Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait,

Source

fn delete<'a, 'life0, 'async_trait, E>( &'life0 mut self, executor: E, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where E: IntoExecutor<'a, DB = DB> + 'async_trait, Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait,

Source

fn has_soft_delete() -> bool

Source

fn find_by_id<'a, 'async_trait, E>( executor: E, id: i32, ) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Error>> + Send + 'async_trait>>
where E: IntoExecutor<'a, DB = DB> + 'async_trait, Self: 'async_trait, 'a: 'async_trait,

Finds a record by its Primary Key.

Provided Methods§

Source

fn eager_load<'a, 'life0, 'life1, 'async_trait, E>( _models: &'life0 mut [Self], _relation: &'life1 str, _executor: E, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where E: IntoExecutor<'a, DB = DB> + 'async_trait, Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn find<'a, E>(executor: E) -> QueryBuilder<'a, Self, DB>
where E: IntoExecutor<'a, DB = DB>,

Source

fn find_in_pool(pool: &Pool<DB>) -> QueryBuilder<'_, Self, DB>

Source

fn find_in_tx(conn: &mut DB::Connection) -> QueryBuilder<'_, Self, DB>

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§