chore: some more api code cleanup
This commit is contained in:
parent
45f1abade3
commit
421f6ae69b
6 changed files with 30 additions and 39 deletions
|
|
@ -9,7 +9,6 @@ use serde::{Deserialize, Serialize};
|
|||
pub use entities::{prelude::*, *};
|
||||
pub use migrator::Migrator;
|
||||
|
||||
|
||||
type Result<T> = std::result::Result<T, sea_orm::DbErr>;
|
||||
|
||||
#[derive(EnumIter, DeriveActiveEnum, Serialize, Deserialize, PartialEq, Eq, Clone, Debug)]
|
||||
|
|
|
|||
|
|
@ -13,8 +13,14 @@ impl IntoCondition for Filter {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn page(conn: &DbConn, per_page: u64, page: u64) -> Result<(u64, Vec<repo::Model>)> {
|
||||
pub async fn page(
|
||||
conn: &DbConn,
|
||||
per_page: u64,
|
||||
page: u64,
|
||||
filter: Filter,
|
||||
) -> Result<(u64, Vec<repo::Model>)> {
|
||||
let paginator = Repo::find()
|
||||
.filter(filter)
|
||||
.order_by_asc(repo::Column::Id)
|
||||
.paginate(conn, per_page);
|
||||
let repos = paginator.fetch_page(page).await?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue