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

Function list

examples/poem_example/api/src/lib.rs:45–65  ·  view source on GitHub ↗
(state: Data<&AppState>, Query(params): Query<Params>)

Source from the content-addressed store, hash-verified

43
44#[handler]
45async fn list(state: Data<&AppState>, Query(params): Query<Params>) -> Result<impl IntoResponse> {
46 let conn = &state.conn;
47 let page = params.page.unwrap_or(1);
48 let posts_per_page = params.posts_per_page.unwrap_or(DEFAULT_POSTS_PER_PAGE);
49
50 let (posts, num_pages) = QueryCore::find_posts_in_page(conn, page, posts_per_page)
51 .await
52 .map_err(InternalServerError)?;
53
54 let mut ctx = tera::Context::new();
55 ctx.insert("posts", &posts);
56 ctx.insert("page", &page);
57 ctx.insert("posts_per_page", &posts_per_page);
58 ctx.insert("num_pages", &num_pages);
59
60 let body = state
61 .templates
62 .render("index.html.tera", &ctx)
63 .map_err(InternalServerError)?;
64 Ok(Html(body))
65}
66
67#[handler]
68async fn new(state: Data<&AppState>) -> Result<impl IntoResponse> {

Callers

nothing calls this directly

Calls 2

newFunction · 0.70
insertMethod · 0.45

Tested by

no test coverage detected