(ctx: &AppContext, id: i32)
| 20 | } |
| 21 | |
| 22 | async fn load_item(ctx: &AppContext, id: i32) -> Result<Model> { |
| 23 | let item = Entity::find_by_id(id).one(&ctx.db).await?; |
| 24 | item.ok_or_else(|| Error::NotFound) |
| 25 | } |
| 26 | |
| 27 | pub async fn list(State(ctx): State<AppContext>) -> Result<Response> { |
| 28 | format::json(Entity::find().all(&ctx.db).await?) |