pub struct PaginatedQueryArgs<T: Debug> {
pub first: usize,
pub after: Option<T>,
}Expand description
A cursor-based pagination structure for efficiently paginating through large datasets
The PaginatedQueryArgs<T> encapsulates a first field that specifies the count of entities to fetch per query, and an optional after field
that specifies the cursor to start from for the current query. The <T> parameter represents cursor type, which depends on the sorting field.
A field’s cursor is generated by EsRepo if it has list_by option.
§Examples
ⓘ
// Initial query - fetch first 10 users after an existing user id
let query_args = PaginatedQueryArgs {
first: 10,
after: Some(user_cursor::UsersByIdCursor {
id: some_existing_user_id // assume this variable exists
}),
};
// Execute query using `query_args` argument of `PaginatedQueryArgs` type
let result = users.list_by_id(query_args, ListDirection::Ascending).await?;
// Continue pagination using the updated `next_query_args` of `PaginatedQueryArgs` type
if result.has_next_page {
let next_query_args = PaginatedQueryArgs {
first: 10,
after: result.end_cursor, // Use cursor from previous result to update `after`
};
let next_result = users.list_by_id(next_query_args, ListDirection::Ascending).await?;
}Fields§
§first: usizeSpecifies the number of entities to fetch per query
after: Option<T>Specifies the cursor/marker to start from for current query
Trait Implementations§
Source§impl<T> Clone for PaginatedQueryArgs<T>
impl<T> Clone for PaginatedQueryArgs<T>
Auto Trait Implementations§
impl<T> Freeze for PaginatedQueryArgs<T>where
T: Freeze,
impl<T> RefUnwindSafe for PaginatedQueryArgs<T>where
T: RefUnwindSafe,
impl<T> Send for PaginatedQueryArgs<T>where
T: Send,
impl<T> Sync for PaginatedQueryArgs<T>where
T: Sync,
impl<T> Unpin for PaginatedQueryArgs<T>where
T: Unpin,
impl<T> UnwindSafe for PaginatedQueryArgs<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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