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

Function update

examples/loco_example/src/controllers/notes.rs:40–50  ·  view source on GitHub ↗
(
    Path(id): Path<i32>,
    State(ctx): State<AppContext>,
    Json(params): Json<Params>,
)

Source from the content-addressed store, hash-verified

38}
39
40pub async fn update(
41 Path(id): Path<i32>,
42 State(ctx): State<AppContext>,
43 Json(params): Json<Params>,
44) -> Result<Response> {
45 let item = load_item(&ctx, id).await?;
46 let mut item = item.into_active_model();
47 params.update(&mut item);
48 let item = item.update(&ctx.db).await?;
49 format::json(item)
50}
51
52pub async fn remove(Path(id): Path<i32>, State(ctx): State<AppContext>) -> Result<Response> {
53 load_item(&ctx, id).await?.delete(&ctx.db).await?;

Callers 5

updateMethod · 0.50
mainFunction · 0.50
create_and_updateFunction · 0.50

Calls 4

jsonFunction · 0.85
into_active_modelMethod · 0.80
load_itemFunction · 0.70
updateMethod · 0.45

Tested by 4

mainFunction · 0.40
create_and_updateFunction · 0.40