MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / delete

Method delete

src/entity/active_model.rs:474–484  ·  view source on GitHub ↗

Delete an active model by its primary key # Example ``` # use sea_orm::{error::*, tests_cfg::*, *}; # # #[smol_potat::main] # #[cfg(feature = "mock")] # pub async fn main() -> Result<(), DbErr> { # # let db = MockDatabase::new(DbBackend::Postgres) # .append_exec_results([ # MockExecResult { # last_insert_id: 0, # rows_affected: 1, # }, # ]) # .

(self, db: &'a C)

Source from the content-addressed store, hash-verified

472 /// # }
473 /// ```
474 async fn delete<'a, C>(self, db: &'a C) -> Result<DeleteResult, DbErr>
475 where
476 Self: ActiveModelBehavior + 'a,
477 C: ConnectionTrait,
478 {
479 let am = ActiveModelBehavior::before_delete(self, db).await?;
480 let am_clone = am.clone();
481 let delete_res = Self::Entity::delete(am).exec(db).await?;
482 ActiveModelBehavior::after_delete(am_clone, db).await?;
483 Ok(delete_res)
484 }
485
486 /// Set the corresponding attributes in the ActiveModel from a JSON value
487 ///

Callers

nothing calls this directly

Calls 2

deleteFunction · 0.50
execMethod · 0.45

Tested by

no test coverage detected