pub struct Cursor<S>where
S: SelectorTrait,{ /* private fields */ }Expand description
Keyset (cursor) pagination over an ordered query.
Unlike Paginator which uses LIMIT / OFFSET,
Cursor paginates by filtering on the configured order column(s) — fast
and stable across concurrent inserts. Build one with
Select::cursor_by (or
CursorTrait-aware helpers on other selects), then drive it with
before / after /
first / last before calling
.all(db) / .one(db).
Implementations§
Source§impl<S> Cursor<S>where
S: SelectorTrait,
impl<S> Cursor<S>where
S: SelectorTrait,
Sourcepub fn before<V>(&mut self, values: V) -> &mut Selfwhere
V: IntoValueTuple,
pub fn before<V>(&mut self, values: V) -> &mut Selfwhere
V: IntoValueTuple,
Filter paginated result with corresponding column less than the input value
Sourcepub fn after<V>(&mut self, values: V) -> &mut Selfwhere
V: IntoValueTuple,
pub fn after<V>(&mut self, values: V) -> &mut Selfwhere
V: IntoValueTuple,
Filter paginated result with corresponding column greater than the input value
Sourcepub fn first(&mut self, num_rows: u64) -> &mut Self
pub fn first(&mut self, num_rows: u64) -> &mut Self
Limit result set to only first N rows in ascending order of the order by column
Sourcepub fn last(&mut self, num_rows: u64) -> &mut Self
pub fn last(&mut self, num_rows: u64) -> &mut Self
Limit result set to only last N rows in ascending order of the order by column
Sourcepub fn all<C>(&mut self, db: &C) -> Result<Vec<S::Item>, DbErr>where
C: ConnectionTrait,
pub fn all<C>(&mut self, db: &C) -> Result<Vec<S::Item>, DbErr>where
C: ConnectionTrait,
Fetch the paginated result
Sourcepub fn into_model<M>(self) -> Cursor<SelectModel<M>>where
M: FromQueryResult,
pub fn into_model<M>(self) -> Cursor<SelectModel<M>>where
M: FromQueryResult,
Construct a Cursor that fetch any custom struct
Sourcepub fn into_partial_model<M>(self) -> Cursor<SelectModel<M>>where
M: PartialModelTrait,
pub fn into_partial_model<M>(self) -> Cursor<SelectModel<M>>where
M: PartialModelTrait,
Restrict the cursor’s projection to a PartialModelTrait type M,
returning a Cursor that yields M instead of the full model.
Sourcepub fn into_json(self) -> Cursor<SelectModel<JsonValue>>
Available on crate feature with-json only.
pub fn into_json(self) -> Cursor<SelectModel<JsonValue>>
with-json only.Construct a Cursor that fetch JSON value
Sourcepub fn set_secondary_order_by(
&mut self,
tbl_col: Vec<(DynIden, Identity)>,
) -> &mut Self
pub fn set_secondary_order_by( &mut self, tbl_col: Vec<(DynIden, Identity)>, ) -> &mut Self
Set the cursor ordering for another table when dealing with SelectTwo
Trait Implementations§
Source§impl<S> QuerySelect for Cursor<S>where
S: SelectorTrait,
impl<S> QuerySelect for Cursor<S>where
S: SelectorTrait,
Source§type QueryStatement = SelectStatement
type QueryStatement = SelectStatement
sea_query statement type (typically SelectStatement).Source§fn query(&mut self) -> &mut SelectStatement
fn query(&mut self) -> &mut SelectStatement
Source§fn select_only(self) -> Self
fn select_only(self) -> Self
Source§fn column<C>(self, col: C) -> Selfwhere
C: ColumnTrait,
fn column<C>(self, col: C) -> Selfwhere
C: ColumnTrait,
Source§fn column_as<C, I>(self, col: C, alias: I) -> Selfwhere
C: ColumnAsExpr,
I: IntoIdentity,
fn column_as<C, I>(self, col: C, alias: I) -> Selfwhere
C: ColumnAsExpr,
I: IntoIdentity,
Source§fn columns<C, I>(self, cols: I) -> Selfwhere
C: ColumnTrait,
I: IntoIterator<Item = C>,
fn columns<C, I>(self, cols: I) -> Selfwhere
C: ColumnTrait,
I: IntoIterator<Item = C>,
Source§fn offset<T>(self, offset: T) -> Self
fn offset<T>(self, offset: T) -> Self
Source§fn limit<T>(self, limit: T) -> Self
fn limit<T>(self, limit: T) -> Self
Source§fn group_by<C>(self, col: C) -> Selfwhere
C: IntoSimpleExpr,
fn group_by<C>(self, col: C) -> Selfwhere
C: IntoSimpleExpr,
Source§fn having<F>(self, filter: F) -> Selfwhere
F: IntoCondition,
fn having<F>(self, filter: F) -> Selfwhere
F: IntoCondition,
Source§fn distinct_on<T, I>(self, cols: I) -> Selfwhere
T: IntoColumnRef,
I: IntoIterator<Item = T>,
fn distinct_on<T, I>(self, cols: I) -> Selfwhere
T: IntoColumnRef,
I: IntoIterator<Item = T>,
sqlx-postgres Read moreSource§fn join(self, join: JoinType, rel: RelationDef) -> Self
fn join(self, join: JoinType, rel: RelationDef) -> Self
RelationDef.Source§fn join_rev(self, join: JoinType, rel: RelationDef) -> Self
fn join_rev(self, join: JoinType, rel: RelationDef) -> Self
RelationDef but in reverse direction.
Assume when there exist a relation A to B.
You can reverse join B from A.Source§fn join_as<I>(self, join: JoinType, rel: RelationDef, alias: I) -> Selfwhere
I: IntoIden,
fn join_as<I>(self, join: JoinType, rel: RelationDef, alias: I) -> Selfwhere
I: IntoIden,
RelationDef with table alias.Source§fn join_as_rev<I>(self, join: JoinType, rel: RelationDef, alias: I) -> Selfwhere
I: IntoIden,
fn join_as_rev<I>(self, join: JoinType, rel: RelationDef, alias: I) -> Selfwhere
I: IntoIden,
RelationDef with table alias but in reverse direction.
Assume when there exist a relation A to B.
You can reverse join B from A.Source§fn lock_exclusive(self) -> Self
fn lock_exclusive(self) -> Self
Source§fn lock_with_behavior(self, type: LockType, behavior: LockBehavior) -> Self
fn lock_with_behavior(self, type: LockType, behavior: LockBehavior) -> Self
Source§fn expr<T>(self, expr: T) -> Selfwhere
T: Into<SelectExpr>,
fn expr<T>(self, expr: T) -> Selfwhere
T: Into<SelectExpr>,
Source§fn exprs<T, I>(self, exprs: I) -> Self
fn exprs<T, I>(self, exprs: I) -> Self
SelectExpr. Read moreSource§fn tbl_col_as<T, C, A>(self, (tbl, col): (T, C), alias: A) -> Self
fn tbl_col_as<T, C, A>(self, (tbl, col): (T, C), alias: A) -> Self
expr_as(Expr::col((T, C)), A). Read moreAuto Trait Implementations§
impl<S> Freeze for Cursor<S>
impl<S> RefUnwindSafe for Cursor<S>where
S: RefUnwindSafe,
impl<S> Send for Cursor<S>where
S: Send,
impl<S> Sync for Cursor<S>where
S: Sync,
impl<S> Unpin for Cursor<S>where
S: Unpin,
impl<S> UnsafeUnpin for Cursor<S>
impl<S> UnwindSafe for Cursor<S>where
S: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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