Struct leetcode_tui_rs::migrations::sea_orm::Paginator
source · pub struct Paginator<'db, C, S>where
C: ConnectionTrait,
S: SelectorTrait + 'db,{ /* private fields */ }
Expand description
Defined a structure to handle pagination of a result from a query operation on a Model
Implementations§
source§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,
sourcepub async fn fetch_page(
&self,
page: u64
) -> impl Future<Output = Result<Vec<<S as SelectorTrait>::Item, Global>, DbErr>>
pub async fn fetch_page( &self, page: u64 ) -> impl Future<Output = Result<Vec<<S as SelectorTrait>::Item, Global>, DbErr>>
Fetch a specific page; page index starts from zero
sourcepub async fn fetch(
&self
) -> impl Future<Output = Result<Vec<<S as SelectorTrait>::Item, Global>, DbErr>>
pub async fn fetch( &self ) -> impl Future<Output = Result<Vec<<S as SelectorTrait>::Item, Global>, DbErr>>
Fetch the current page
sourcepub async fn num_items(&self) -> impl Future<Output = Result<u64, DbErr>>
pub async fn num_items(&self) -> impl Future<Output = Result<u64, DbErr>>
Get the total number of items
sourcepub async fn num_pages(&self) -> impl Future<Output = Result<u64, DbErr>>
pub async fn num_pages(&self) -> impl Future<Output = Result<u64, DbErr>>
Get the total number of pages
sourcepub async fn num_items_and_pages(
&self
) -> impl Future<Output = Result<ItemsAndPagesNumber, DbErr>>
pub async fn num_items_and_pages( &self ) -> impl Future<Output = Result<ItemsAndPagesNumber, DbErr>>
Get the total number of items and pages
sourcepub async fn fetch_and_next(
&mut self
) -> impl Future<Output = Result<Option<Vec<<S as SelectorTrait>::Item, Global>>, DbErr>>
pub async fn fetch_and_next( &mut self ) -> impl Future<Output = Result<Option<Vec<<S as SelectorTrait>::Item, Global>>, 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>
}
sourcepub fn into_stream(
self
) -> Pin<Box<dyn Stream<Item = Result<Vec<<S as SelectorTrait>::Item, Global>, DbErr>> + 'db, Global>>
pub fn into_stream( self ) -> Pin<Box<dyn Stream<Item = Result<Vec<<S as SelectorTrait>::Item, Global>, DbErr>> + 'db, Global>>
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§
source§impl<'db, C, S> Clone for Paginator<'db, C, S>where
C: Clone + ConnectionTrait,
S: Clone + SelectorTrait + 'db,
impl<'db, C, S> Clone for Paginator<'db, C, S>where C: Clone + ConnectionTrait, S: Clone + SelectorTrait + 'db,
Auto Trait Implementations§
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