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

Function create

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

Source from the content-addressed store, hash-verified

30#[openapi(tag = "POST")]
31#[post("/", data = "<post_data>")]
32async fn create(conn: Connection<Db>, post_data: DataResult<'_, post::Model>) -> R<Option<String>> {
33 let db = conn.into_inner();
34 let form = post_data?.into_inner();
35 let cmd = Mutation::create_post(&db, form);
36 match cmd.await {
37 Ok(_) => Ok(Json(Some("Post successfully added.".to_string()))),
38 Err(e) => {
39 let m = error::Error {
40 err: "Could not insert post".to_string(),
41 msg: Some(e.to_string()),
42 http_status_code: 400,
43 };
44 Err(m)
45 }
46 }
47}
48
49/// # Update a post
50#[openapi(tag = "POST")]

Callers 1

upMethod · 0.50

Calls 2

create_postFunction · 0.85
into_innerMethod · 0.80

Tested by

no test coverage detected