Struct Paginator
pub struct Paginator<'db, C, S>where
    C: ConnectionTrait,
    S: SelectorTrait + 'db,{
    pub(crate) query: SelectStatement,
    pub(crate) page: u64,
    pub(crate) page_size: u64,
    pub(crate) db: &'db C,
    pub(crate) selector: PhantomData<S>,
}Expand description
Defined a structure to handle pagination of a result from a query operation on a Model
Fields§
§query: SelectStatement§page: u64§page_size: u64§db: &'db C§selector: PhantomData<S>Implementations§
§impl<'db, C, S> Paginator<'db, C, S>where
    C: ConnectionTrait,
    S: SelectorTrait + 'db,
 
impl<'db, C, S> Paginator<'db, C, S>where
    C: ConnectionTrait,
    S: SelectorTrait + 'db,
pub async fn fetch_page(
    &self,
    page: u64,
) -> Result<Vec<<S as SelectorTrait>::Item>, DbErr>
pub async fn fetch_page( &self, page: u64, ) -> Result<Vec<<S as SelectorTrait>::Item>, DbErr>
Fetch a specific page; page index starts from zero
pub async fn num_items_and_pages(&self) -> Result<ItemsAndPagesNumber, DbErr>
pub async fn num_items_and_pages(&self) -> Result<ItemsAndPagesNumber, DbErr>
Get the total number of items and pages
pub fn next(&mut self)
pub fn next(&mut self)
Increment the page counter
pub async fn fetch_and_next(
    &mut self,
) -> Result<Option<Vec<<S as SelectorTrait>::Item>>, DbErr>
pub async fn fetch_and_next( &mut self, ) -> Result<Option<Vec<<S as SelectorTrait>::Item>>, DbErr>
Fetch one page and increment the page counter
use sea_orm::{entity::*, query::*, tests_cfg::cake};
let mut cake_pages = cake::Entity::find()
    .order_by_asc(cake::Column::Id)
    .paginate(db, 50);
while let Some(cakes) = cake_pages.fetch_and_next().await? {
    // Do something on cakes: Vec<cake::Model>
}pub fn into_stream(
    self,
) -> Pin<Box<dyn Stream<Item = Result<Vec<<S as SelectorTrait>::Item>, DbErr>> + 'db>>
pub fn into_stream( self, ) -> Pin<Box<dyn Stream<Item = Result<Vec<<S as SelectorTrait>::Item>, DbErr>> + 'db>>
Convert self into an async stream
use futures::TryStreamExt;
use sea_orm::{entity::*, query::*, tests_cfg::cake};
let mut cake_stream = cake::Entity::find()
    .order_by_asc(cake::Column::Id)
    .paginate(db, 50)
    .into_stream();
while let Some(cakes) = cake_stream.try_next().await? {
    // Do something on cakes: Vec<cake::Model>
}Trait Implementations§
Auto Trait Implementations§
impl<'db, C, S> Freeze for Paginator<'db, C, S>
impl<'db, C, S> !RefUnwindSafe for Paginator<'db, C, S>
impl<'db, C, S> Send for Paginator<'db, C, S>where
    S: Send,
impl<'db, C, S> Sync for Paginator<'db, C, S>where
    S: Sync,
impl<'db, C, S> Unpin for Paginator<'db, C, S>where
    S: Unpin,
impl<'db, C, S> !UnwindSafe for Paginator<'db, C, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
§impl<T> Instrument for T
 
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
 
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts 
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts 
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more