pub trait ModelDelete: Model {
// Required method
fn delete(conn: &mut SqliteConnection, id: &Self::Id) -> QueryResult<usize>;
// Provided method
fn delete_all(
conn: &mut SqliteConnection,
ids: Vec<&Self::Id>,
) -> QueryResult<usize> { ... }
}Expand description
A trait for models that support deletion operations.
This trait extends the Model trait and provides methods for deleting
individual and multiple records.
§Methods
delete: Deletes a record from the database table.delete_all: Deletes multiple records from the database table.
Required Methods§
Sourcefn delete(conn: &mut SqliteConnection, id: &Self::Id) -> QueryResult<usize>
fn delete(conn: &mut SqliteConnection, id: &Self::Id) -> QueryResult<usize>
Provided Methods§
Sourcefn delete_all(
conn: &mut SqliteConnection,
ids: Vec<&Self::Id>,
) -> QueryResult<usize>
fn delete_all( conn: &mut SqliteConnection, ids: Vec<&Self::Id>, ) -> QueryResult<usize>
Deletes multiple records from the database table.
Delete in input order within one transaction. A failure rolls back the entire batch. Tree models override this to handle overlapping subtrees without deleting twice.
§Arguments
conn: A mutable reference to the database connection.ids: A vector of references to the IDs of the records to delete.
§Returns
A QueryResult containing the total number of rows affected.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".