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

Function update

examples/rocket_okapi_example/api/src/okapi_example.rs:52–73  ·  view source on GitHub ↗
(
    conn: Connection<Db>,
    id: i32,
    post_data: DataResult<'_, post::Model>,
)

Source from the content-addressed store, hash-verified

50#[openapi(tag = "POST")]
51#[post("/<id>", data = "<post_data>")]
52async fn update(
53 conn: Connection<Db>,
54 id: i32,
55 post_data: DataResult<'_, post::Model>,
56) -> R<Option<String>> {
57 let db = conn.into_inner();
58
59 let form = post_data?.into_inner();
60
61 let cmd = Mutation::update_post_by_id(&db, id, form);
62 match cmd.await {
63 Ok(_) => Ok(Json(Some("Post successfully updated.".to_string()))),
64 Err(e) => {
65 let m = error::Error {
66 err: "Could not update post".to_string(),
67 msg: Some(e.to_string()),
68 http_status_code: 400,
69 };
70 Err(m)
71 }
72 }
73}
74
75/// # Get post list
76#[openapi(tag = "POST")]

Callers

nothing calls this directly

Calls 1

into_innerMethod · 0.80

Tested by

no test coverage detected