pub trait Model<DB>:
Sized
+ Send
+ Sync
+ Unpin{
Show 14 methods
// Required methods
fn table_name() -> &'static str;
fn create_table_sql() -> String;
fn list_columns() -> Vec<String>;
fn save<'a, E>(
&'a mut self,
executor: E,
) -> impl Future<Output = Result<(), Error>> + Send
where E: IntoExecutor<'a, DB = DB>;
fn update<'a, E>(
&'a mut self,
executor: E,
) -> impl Future<Output = Result<UpdateResult, Error>> + Send
where E: IntoExecutor<'a, DB = DB>;
fn delete<'a, E>(
&'a mut self,
executor: E,
) -> impl Future<Output = Result<(), Error>> + Send
where E: IntoExecutor<'a, DB = DB>;
fn has_soft_delete() -> bool;
fn find_by_id<'a, E>(
executor: E,
id: i32,
) -> impl Future<Output = Result<Option<Self>, Error>> + Send
where E: IntoExecutor<'a, DB = DB>;
// Provided methods
fn sensitive_fields() -> &'static [&'static str] { ... }
fn raw_sql<'q>(
sql: &'q str,
) -> QueryAs<'q, DB, Self, <DB as Database>::Arguments<'q>> { ... }
fn eager_load<'a>(
_models: &mut [Self],
_relation: &str,
_executor: Executor<'a, DB>,
) -> impl Future<Output = Result<(), Error>> + Send { ... }
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, E>(
&'a mut self,
executor: E,
) -> impl Future<Output = Result<(), Error>> + Sendwhere
E: IntoExecutor<'a, DB = DB>,
fn save<'a, E>(
&'a mut self,
executor: E,
) -> impl Future<Output = Result<(), Error>> + Sendwhere
E: IntoExecutor<'a, DB = DB>,
Saves the current instance to the database.
fn update<'a, E>(
&'a mut self,
executor: E,
) -> impl Future<Output = Result<UpdateResult, Error>> + Sendwhere
E: IntoExecutor<'a, DB = DB>,
fn delete<'a, E>(
&'a mut self,
executor: E,
) -> impl Future<Output = Result<(), Error>> + Sendwhere
E: IntoExecutor<'a, DB = DB>,
fn has_soft_delete() -> bool
Sourcefn find_by_id<'a, E>(
executor: E,
id: i32,
) -> impl Future<Output = Result<Option<Self>, Error>> + Sendwhere
E: IntoExecutor<'a, DB = DB>,
fn find_by_id<'a, E>(
executor: E,
id: i32,
) -> impl Future<Output = Result<Option<Self>, Error>> + Sendwhere
E: IntoExecutor<'a, DB = DB>,
Finds a record by its Primary Key.
Provided Methods§
fn sensitive_fields() -> &'static [&'static str]
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>( _models: &mut [Self], _relation: &str, _executor: Executor<'a, DB>, ) -> impl Future<Output = Result<(), Error>> + Send
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.