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

Method update_note_by_id

examples/graphql_example/service/src/mutation.rs:21–39  ·  view source on GitHub ↗
(
        db: &DbConn,
        id: i32,
        form_data: note::Model,
    )

Source from the content-addressed store, hash-verified

19 }
20
21 pub async fn update_note_by_id(
22 db: &DbConn,
23 id: i32,
24 form_data: note::Model,
25 ) -> Result<note::Model, DbErr> {
26 let note: note::ActiveModel = Note::find_by_id(id)
27 .one(db)
28 .await?
29 .ok_or(DbErr::Custom("Cannot find note.".to_owned()))
30 .map(Into::into)?;
31
32 note::ActiveModel {
33 id: note.id,
34 title: Set(form_data.title.to_owned()),
35 text: Set(form_data.text.to_owned()),
36 }
37 .update(db)
38 .await
39 }
40
41 pub async fn delete_note(db: &DbConn, id: i32) -> Result<DeleteResult, DbErr> {
42 let note: note::ActiveModel = Note::find_by_id(id)

Callers

nothing calls this directly

Calls 2

oneMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected