pub struct PaginatedQueryArgs<T>where
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::UserByIdCursor {
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>
Source§fn clone(&self) -> PaginatedQueryArgs<T>
fn clone(&self) -> PaginatedQueryArgs<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for PaginatedQueryArgs<T>where
T: Debug,
impl<T> Debug for PaginatedQueryArgs<T>where
T: Debug,
Source§impl<T> Default for PaginatedQueryArgs<T>where
T: Debug,
impl<T> Default for PaginatedQueryArgs<T>where
T: Debug,
Source§fn default() -> PaginatedQueryArgs<T>
fn default() -> PaginatedQueryArgs<T>
Default value fetches first 100 entities
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> UnsafeUnpin for PaginatedQueryArgs<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for PaginatedQueryArgs<T>where
T: UnwindSafe,
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,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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