cargo fmt

This commit is contained in:
Chris Tsang 2021-09-10 22:02:35 +08:00
parent 81c1bf0704
commit f96c8ed49b
2 changed files with 12 additions and 6 deletions

View File

@ -73,13 +73,17 @@ async fn update(conn: Connection<Db>, id: i32, post_form: Form<post::Model>) ->
} }
#[get("/?<page>")] #[get("/?<page>")]
async fn list(conn: Connection<Db>, page: Option<usize>, flash: Option<FlashMessage<'_>>) -> Template { async fn list(
conn: Connection<Db>,
page: Option<usize>,
flash: Option<FlashMessage<'_>>,
) -> Template {
let page = page.unwrap_or(0); let page = page.unwrap_or(0);
let paginator = Post::find() let paginator = Post::find().paginate(&conn, ROWS_PER_PAGE);
.paginate(&conn, ROWS_PER_PAGE);
let num_pages = paginator.num_pages().await.ok().unwrap(); let num_pages = paginator.num_pages().await.ok().unwrap();
let posts = paginator.fetch_page(page) let posts = paginator
.fetch_page(page)
.await .await
.expect("could not retrieve posts"); .expect("could not retrieve posts");
@ -91,7 +95,7 @@ async fn list(conn: Connection<Db>, page: Option<usize>, flash: Option<FlashMess
posts: posts, posts: posts,
flash: flash, flash: flash,
page: page, page: page,
num_pages: num_pages num_pages: num_pages,
}, },
) )
} }

View File

@ -3,7 +3,9 @@ use crate::{
PrimaryKeyToColumn, RelationDef, PrimaryKeyToColumn, RelationDef,
}; };
pub use sea_query::{Condition, ConditionalStatement, DynIden, JoinType, Order, OrderedStatement}; pub use sea_query::{Condition, ConditionalStatement, DynIden, JoinType, Order, OrderedStatement};
use sea_query::{Expr, IntoCondition, LockType, SeaRc, SelectExpr, SelectStatement, SimpleExpr, TableRef}; use sea_query::{
Expr, IntoCondition, LockType, SeaRc, SelectExpr, SelectStatement, SimpleExpr, TableRef,
};
// LINT: when the column does not appear in tables selected from // LINT: when the column does not appear in tables selected from
// LINT: when there is a group by clause, but some columns don't have aggregate functions // LINT: when there is a group by clause, but some columns don't have aggregate functions