If ok, returns (note models, num pages).
(
db: &DbConn,
page: u64,
notes_per_page: u64,
)
| 14 | |
| 15 | /// If ok, returns (note models, num pages). |
| 16 | pub async fn find_notes_in_page( |
| 17 | db: &DbConn, |
| 18 | page: u64, |
| 19 | notes_per_page: u64, |
| 20 | ) -> Result<(Vec<note::Model>, u64), DbErr> { |
| 21 | // Setup paginator |
| 22 | let paginator = Note::find() |
| 23 | .order_by_asc(note::Column::Id) |
| 24 | .paginate(db, notes_per_page); |
| 25 | let num_pages = paginator.num_pages().await?; |
| 26 | |
| 27 | // Fetch paginated notes |
| 28 | paginator.fetch_page(page - 1).await.map(|p| (p, num_pages)) |
| 29 | } |
| 30 | } |
nothing calls this directly
no test coverage detected