Model

Trait Model 

Source
pub trait Model<DB>:
    Sized
    + Send
    + Sync
    + Unpin
where DB: SqlDialect + Database, for<'r> Self: FromRow<'r, DB::Row>,
{
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§

Source

fn table_name() -> &'static str

Source

fn create_table_sql() -> String

Source

fn list_columns() -> Vec<String>

Source

fn save<'a, E>( &'a mut self, executor: E, ) -> impl Future<Output = Result<(), Error>> + Send
where E: IntoExecutor<'a, DB = DB>,

Saves the current instance to the database.

Source

fn update<'a, E>( &'a mut self, executor: E, ) -> impl Future<Output = Result<UpdateResult, Error>> + Send
where E: IntoExecutor<'a, DB = DB>,

Source

fn delete<'a, E>( &'a mut self, executor: E, ) -> impl Future<Output = Result<(), Error>> + Send
where E: IntoExecutor<'a, DB = DB>,

Source

fn has_soft_delete() -> bool

Source

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

Finds a record by its Primary Key.

Provided Methods§

Source

fn sensitive_fields() -> &'static [&'static str]

Source

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.

Source

fn eager_load<'a>( _models: &mut [Self], _relation: &str, _executor: Executor<'a, DB>, ) -> impl Future<Output = Result<(), Error>> + Send

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§