pub trait Model<DB>:
Sized
+ Send
+ Sync
+ Unpin{
Show 13 methods
// 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 raw_sql<'q>(
sql: &'q str,
) -> QueryAs<'q, DB, Self, <DB as Database>::Arguments<'q>> { ... }
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§
fn table_name() -> &'static str
fn create_table_sql() -> String
fn list_columns() -> Vec<String>
Sourcefn 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 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.
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
Provided Methods§
Sourcefn raw_sql<'q>(
sql: &'q str,
) -> QueryAs<'q, DB, Self, <DB as Database>::Arguments<'q>>
fn raw_sql<'q>( sql: &'q str, ) -> QueryAs<'q, DB, Self, <DB as Database>::Arguments<'q>>
Use raw SQL and map rows into the current model type.
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>
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.