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

Method update

src/entity/active_model.rs:396–405  ·  view source on GitHub ↗

Perform the `UPDATE` operation on an ActiveModel # Example (Postgres) ``` # 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_query_results([ # [fruit::Model { # id: 1, # name: "Orange".to_owned(), #

(self, db: &'a C)

Source from the content-addressed store, hash-verified

394 /// # }
395 /// ```
396 async fn update<'a, C>(self, db: &'a C) -> Result<<Self::Entity as EntityTrait>::Model, DbErr>
397 where
398 <Self::Entity as EntityTrait>::Model: IntoActiveModel<Self>,
399 Self: ActiveModelBehavior + 'a,
400 C: ConnectionTrait,
401 {
402 let am = ActiveModelBehavior::before_save(self, db, false).await?;
403 let model: <Self::Entity as EntityTrait>::Model = Self::Entity::update(am).exec(db).await?;
404 Self::after_save(model, db, false).await
405 }
406
407 /// Insert the model if primary key is `NotSet`, update otherwise.
408 /// Only works if the entity has auto increment primary key.

Callers 2

saveMethod · 0.45
test_reset_2Function · 0.45

Calls 2

updateFunction · 0.50
execMethod · 0.45

Tested by 1

test_reset_2Function · 0.36