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

Method update_post_by_id

examples/jsonrpsee_example/service/src/mutation.rs:20–38  ·  view source on GitHub ↗
(
        db: &DbConn,
        id: i32,
        form_data: post::Model,
    )

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

oneMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected