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

Function cursor_related_pagination

tests/cursor_tests.rs:611–942  ·  view source on GitHub ↗
(db: &DatabaseConnection)

Source from the content-addressed store, hash-verified

609}
610
611pub async fn cursor_related_pagination(db: &DatabaseConnection) -> Result<(), DbErr> {
612 use common::bakery_chain::*;
613
614 assert_eq!(
615 bakery::Entity::find()
616 .cursor_by(bakery::Column::Id)
617 .before(5)
618 .first(4)
619 .all(db)
620 .await?,
621 [bakery(1), bakery(2), bakery(3), bakery(4),]
622 );
623
624 assert_eq!(
625 bakery::Entity::find()
626 .cursor_by(bakery::Column::Id)
627 .before(5)
628 .first(4)
629 .desc()
630 .all(db)
631 .await?,
632 [bakery(10), bakery(9), bakery(8), bakery(7),]
633 );
634
635 assert_eq!(
636 bakery::Entity::find()
637 .find_also_related(Baker)
638 .cursor_by(bakery::Column::Id)
639 .before(5)
640 .first(20)
641 .all(db)
642 .await?,
643 [
644 (bakery(1), Some(baker('A'))),
645 (bakery(1), Some(baker('K'))),
646 (bakery(1), Some(baker('U'))),
647 (bakery(2), Some(baker('B'))),
648 (bakery(2), Some(baker('L'))),
649 (bakery(2), Some(baker('V'))),
650 (bakery(3), Some(baker('C'))),
651 (bakery(3), Some(baker('M'))),
652 (bakery(3), Some(baker('W'))),
653 (bakery(4), Some(baker('D'))),
654 (bakery(4), Some(baker('N'))),
655 (bakery(4), Some(baker('X'))),
656 ]
657 );
658
659 assert_eq!(
660 bakery::Entity::find()
661 .find_also_related(Baker)
662 .cursor_by(bakery::Column::Id)
663 .after(5)
664 .last(20)
665 .desc()
666 .all(db)
667 .await?,
668 [

Callers 1

cursor_testsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected