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

Method find_notes_in_page

examples/graphql_example/service/src/query.rs:16–29  ·  view source on GitHub ↗

If ok, returns (note models, num pages).

(
        db: &DbConn,
        page: u64,
        notes_per_page: u64,
    )

Source from the content-addressed store, hash-verified

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}

Callers

nothing calls this directly

Calls 4

paginateMethod · 0.80
order_by_ascMethod · 0.80
num_pagesMethod · 0.80
fetch_pageMethod · 0.80

Tested by

no test coverage detected